react-native-enriched-html 0.0.0 → 1.1.0-nightly-20260617-3dfd09072
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 +402 -0
- package/ReactNativeEnrichedHtml.podspec +31 -0
- package/android/build.gradle +106 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +203 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +74 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextViewManagerDelegate.java +70 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextViewManagerInterface.java +31 -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 +456 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/EventEmitters.h +410 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/Props.cpp +272 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/Props.h +1595 -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 +22 -0
- package/android/src/main/java/com/swmansion/enriched/common/AllowFontScaling.kt +36 -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 +16 -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 +9 -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 +1034 -0
- package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt +82 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedAlignmentSpan.kt +19 -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 +185 -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/text/EnrichedTextMovementMethod.kt +75 -0
- package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextSpanFactory.kt +83 -0
- package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextStyle.kt +202 -0
- package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextView.kt +361 -0
- package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextViewManager.kt +157 -0
- package/android/src/main/java/com/swmansion/enriched/text/MeasurementStore.kt +170 -0
- package/android/src/main/java/com/swmansion/enriched/text/events/OnLinkPressEvent.kt +23 -0
- package/android/src/main/java/com/swmansion/enriched/text/events/OnMentionPressEvent.kt +32 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextAlignmentSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextBlockQuoteSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextBoldSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextCheckboxListSpan.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextCodeBlockSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH1Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH2Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH3Span.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH4Span.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH5Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH6Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextImageSpan.kt +57 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextInlineCodeSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextItalicSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextLinkSpan.kt +41 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextMentionSpan.kt +63 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextOrderedListSpan.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextStrikeThroughSpan.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextUnderlineSpan.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextUnorderedListSpan.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/interfaces/EnrichedTextClickableSpan.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/interfaces/EnrichedTextSpan.kt +10 -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 +85 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt +1141 -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 +500 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/MeasurementStore.kt +230 -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/EnrichedInputAlignmentSpan.kt +14 -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 +45 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedSpans.kt +240 -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/AlignmentStyles.kt +367 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/HtmlStyle.kt +371 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/InlineStyles.kt +232 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ListStyles.kt +260 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt +439 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt +408 -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 +340 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpanState.kt +318 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannable.kt +156 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannableStringBuilder.kt +59 -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/ShortcutsHandler.kt +150 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/StyleUtils.kt +51 -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 +109 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedTextWatcher.kt +106 -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 +16 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextComponentDescriptor.h +32 -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/EnrichedTextMeasurementManager.cpp +45 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextMeasurementManager.h +25 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextShadowNode.cpp +21 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextShadowNode.h +39 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/conversions.h +44 -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 +54 -0
- package/ios/EnrichedTextInputView.mm +2170 -0
- package/ios/EnrichedTextInputViewManager.mm +13 -0
- package/ios/EnrichedTextView.h +35 -0
- package/ios/EnrichedTextView.mm +806 -0
- package/ios/EnrichedTextViewManager.mm +13 -0
- package/ios/config/EnrichedConfig.h +114 -0
- package/ios/config/EnrichedConfig.mm +727 -0
- package/ios/enrichedInputTextView/EnrichedInputTextView.h +6 -0
- package/ios/enrichedInputTextView/EnrichedInputTextView.mm +334 -0
- package/ios/enrichedTextTextView/EnrichedTextTextView.h +16 -0
- package/ios/enrichedTextTextView/EnrichedTextTextView.mm +71 -0
- package/ios/extensions/ColorExtension.h +8 -0
- package/ios/extensions/ColorExtension.mm +48 -0
- package/ios/extensions/FontExtension.h +11 -0
- package/ios/extensions/FontExtension.mm +72 -0
- package/ios/extensions/ImageExtension.h +33 -0
- package/ios/extensions/ImageExtension.mm +176 -0
- package/ios/extensions/LayoutManagerExtension.h +6 -0
- package/ios/extensions/LayoutManagerExtension.mm +454 -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 +456 -0
- package/ios/generated/ReactNativeEnrichedSpec/EventEmitters.h +410 -0
- package/ios/generated/ReactNativeEnrichedSpec/Props.cpp +272 -0
- package/ios/generated/ReactNativeEnrichedSpec/Props.h +1595 -0
- package/ios/generated/ReactNativeEnrichedSpec/RCTComponentViewHelpers.h +570 -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/htmlParser/HtmlParser.h +11 -0
- package/ios/htmlParser/HtmlParser.mm +1468 -0
- package/ios/inputAttributesManager/InputAttributesManager.h +18 -0
- package/ios/inputAttributesManager/InputAttributesManager.mm +222 -0
- package/ios/inputHtmlParser/InputHtmlParser.h +10 -0
- package/ios/inputHtmlParser/InputHtmlParser.mm +225 -0
- package/ios/interfaces/AlignmentEntry.h +9 -0
- package/ios/interfaces/AlignmentEntry.mm +4 -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/EnrichedTextStyleHeaders.h +62 -0
- package/ios/interfaces/EnrichedViewHost.h +26 -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 +43 -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 +17 -0
- package/ios/interfaces/MentionStyleProps.mm +80 -0
- package/ios/interfaces/StyleBase.h +38 -0
- package/ios/interfaces/StyleBase.mm +279 -0
- package/ios/interfaces/StyleHeaders.h +110 -0
- package/ios/interfaces/StylePair.h +9 -0
- package/ios/interfaces/StylePair.mm +4 -0
- package/ios/interfaces/StyleTypeEnum.h +27 -0
- package/ios/interfaces/TextDecorationLineEnum.h +6 -0
- package/ios/interfaces/TextDecorationLineEnum.mm +4 -0
- package/ios/internals/EnrichedTextComponentDescriptor.h +19 -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/internals/EnrichedTextViewShadowNode.h +34 -0
- package/ios/internals/EnrichedTextViewShadowNode.mm +72 -0
- package/ios/internals/EnrichedTextViewState.cpp +7 -0
- package/ios/internals/EnrichedTextViewState.h +18 -0
- package/ios/styles/AlignmentStyle.mm +203 -0
- package/ios/styles/BlockQuoteStyle.mm +54 -0
- package/ios/styles/BoldStyle.mm +37 -0
- package/ios/styles/CheckboxListStyle.mm +154 -0
- package/ios/styles/CodeBlockStyle.mm +49 -0
- package/ios/styles/EnrichedTextStyles.mm +61 -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 +96 -0
- package/ios/styles/ImageStyle.mm +150 -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 +541 -0
- package/ios/styles/OrderedListStyle.mm +48 -0
- package/ios/styles/StrikethroughStyle.mm +25 -0
- package/ios/styles/UnderlineStyle.mm +24 -0
- package/ios/styles/UnorderedListStyle.mm +48 -0
- package/ios/textHtmlParser/TextHtmlParser.h +10 -0
- package/ios/textHtmlParser/TextHtmlParser.mm +181 -0
- package/ios/utils/AlignmentUtils.h +20 -0
- package/ios/utils/AlignmentUtils.mm +111 -0
- package/ios/utils/AttachmentLayoutUtils.h +24 -0
- package/ios/utils/AttachmentLayoutUtils.mm +144 -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/EnrichedTextTouchHandler.h +14 -0
- package/ios/utils/EnrichedTextTouchHandler.mm +152 -0
- package/ios/utils/KeyboardUtils.h +7 -0
- package/ios/utils/KeyboardUtils.mm +30 -0
- package/ios/utils/OccurenceUtils.h +44 -0
- package/ios/utils/OccurenceUtils.mm +185 -0
- package/ios/utils/ParagraphAttributesUtils.h +18 -0
- package/ios/utils/ParagraphAttributesUtils.mm +289 -0
- package/ios/utils/RangeUtils.h +12 -0
- package/ios/utils/RangeUtils.mm +183 -0
- package/ios/utils/ShortcutsUtils.h +21 -0
- package/ios/utils/ShortcutsUtils.mm +486 -0
- package/ios/utils/StyleUtils.h +33 -0
- package/ios/utils/StyleUtils.mm +290 -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 +60 -0
- package/ios/utils/TextListsUtils.h +40 -0
- package/ios/utils/TextListsUtils.mm +93 -0
- package/ios/utils/WeakBox.h +3 -0
- package/ios/utils/WeakBox.m +4 -0
- package/ios/utils/WordsUtils.h +7 -0
- package/ios/utils/WordsUtils.mm +98 -0
- package/ios/utils/ZeroWidthSpaceUtils.h +14 -0
- package/ios/utils/ZeroWidthSpaceUtils.mm +310 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/index.native.js +7 -0
- package/lib/module/index.native.js.map +1 -0
- package/lib/module/native/EnrichedText.js +76 -0
- package/lib/module/native/EnrichedText.js.map +1 -0
- package/lib/module/native/EnrichedTextInput.js +306 -0
- package/lib/module/native/EnrichedTextInput.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/spec/EnrichedTextInputNativeComponent.ts +524 -0
- package/lib/module/spec/EnrichedTextNativeComponent.ts +110 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/EnrichedTextInputDefaultProps.js +20 -0
- package/lib/module/utils/EnrichedTextInputDefaultProps.js.map +1 -0
- package/lib/module/utils/defaultHtmlStyle.js +83 -0
- package/lib/module/utils/defaultHtmlStyle.js.map +1 -0
- package/lib/module/utils/expandMentionStylesForIndicators.js +15 -0
- package/lib/module/utils/expandMentionStylesForIndicators.js.map +1 -0
- package/lib/module/utils/isMentionStyleRecord.js +10 -0
- package/lib/module/utils/isMentionStyleRecord.js.map +1 -0
- package/lib/module/utils/normalizeHtmlStyle.js +126 -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/module/web/EnrichedTextInput.css +201 -0
- package/lib/module/web/EnrichedTextInput.js +314 -0
- package/lib/module/web/EnrichedTextInput.js.map +1 -0
- package/lib/module/web/adaptWebToNativeEvent.js +34 -0
- package/lib/module/web/adaptWebToNativeEvent.js.map +1 -0
- package/lib/module/web/checkboxHtmlNormalizer.js +54 -0
- package/lib/module/web/checkboxHtmlNormalizer.js.map +1 -0
- package/lib/module/web/formats/EnrichedBlockquote.js +32 -0
- package/lib/module/web/formats/EnrichedBlockquote.js.map +1 -0
- package/lib/module/web/formats/EnrichedBold.js +22 -0
- package/lib/module/web/formats/EnrichedBold.js.map +1 -0
- package/lib/module/web/formats/EnrichedCheckboxItem.js +32 -0
- package/lib/module/web/formats/EnrichedCheckboxItem.js.map +1 -0
- package/lib/module/web/formats/EnrichedCheckboxList.js +35 -0
- package/lib/module/web/formats/EnrichedCheckboxList.js.map +1 -0
- package/lib/module/web/formats/EnrichedCode.js +15 -0
- package/lib/module/web/formats/EnrichedCode.js.map +1 -0
- package/lib/module/web/formats/EnrichedCodeBlock.js +43 -0
- package/lib/module/web/formats/EnrichedCodeBlock.js.map +1 -0
- package/lib/module/web/formats/EnrichedHeading.js +27 -0
- package/lib/module/web/formats/EnrichedHeading.js.map +1 -0
- package/lib/module/web/formats/EnrichedImage.js +57 -0
- package/lib/module/web/formats/EnrichedImage.js.map +1 -0
- package/lib/module/web/formats/EnrichedImageNodeView.js +90 -0
- package/lib/module/web/formats/EnrichedImageNodeView.js.map +1 -0
- package/lib/module/web/formats/EnrichedItalic.js +22 -0
- package/lib/module/web/formats/EnrichedItalic.js.map +1 -0
- package/lib/module/web/formats/EnrichedLink.js +140 -0
- package/lib/module/web/formats/EnrichedLink.js.map +1 -0
- package/lib/module/web/formats/EnrichedListItem.js +19 -0
- package/lib/module/web/formats/EnrichedListItem.js.map +1 -0
- package/lib/module/web/formats/EnrichedMention.js +50 -0
- package/lib/module/web/formats/EnrichedMention.js.map +1 -0
- package/lib/module/web/formats/EnrichedOrderedList.js +32 -0
- package/lib/module/web/formats/EnrichedOrderedList.js.map +1 -0
- package/lib/module/web/formats/EnrichedStrike.js +22 -0
- package/lib/module/web/formats/EnrichedStrike.js.map +1 -0
- package/lib/module/web/formats/EnrichedUnderline.js +22 -0
- package/lib/module/web/formats/EnrichedUnderline.js.map +1 -0
- package/lib/module/web/formats/EnrichedUnorderedList.js +33 -0
- package/lib/module/web/formats/EnrichedUnorderedList.js.map +1 -0
- package/lib/module/web/formats/applyWrappingListToSelection.js +63 -0
- package/lib/module/web/formats/applyWrappingListToSelection.js.map +1 -0
- package/lib/module/web/formats/formatRules.js +48 -0
- package/lib/module/web/formats/formatRules.js.map +1 -0
- package/lib/module/web/formats/listKeyboard.js +50 -0
- package/lib/module/web/formats/listKeyboard.js.map +1 -0
- package/lib/module/web/formats/wrappedBlockKeyboard.js +58 -0
- package/lib/module/web/formats/wrappedBlockKeyboard.js.map +1 -0
- package/lib/module/web/pasteImages.js +78 -0
- package/lib/module/web/pasteImages.js.map +1 -0
- package/lib/module/web/pastedImageDimensions.js +49 -0
- package/lib/module/web/pastedImageDimensions.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/index.js +36 -0
- package/lib/module/web/pmPlugins/MentionPlugin/index.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/isCaretInBlockedContext.js +11 -0
- package/lib/module/web/pmPlugins/MentionPlugin/isCaretInBlockedContext.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/makeMentionPluginState.js +67 -0
- package/lib/module/web/pmPlugins/MentionPlugin/makeMentionPluginState.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/mentionPluginKey.js +5 -0
- package/lib/module/web/pmPlugins/MentionPlugin/mentionPluginKey.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/removeMentionMarksIfSpansResized.js +56 -0
- package/lib/module/web/pmPlugins/MentionPlugin/removeMentionMarksIfSpansResized.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/setMention.js +58 -0
- package/lib/module/web/pmPlugins/MentionPlugin/setMention.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/startMention.js +9 -0
- package/lib/module/web/pmPlugins/MentionPlugin/startMention.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/stripPartialMentionMarks.js +9 -0
- package/lib/module/web/pmPlugins/MentionPlugin/stripPartialMentionMarks.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/subscribeMentionEvents.js +100 -0
- package/lib/module/web/pmPlugins/MentionPlugin/subscribeMentionEvents.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/types.js +4 -0
- package/lib/module/web/pmPlugins/MentionPlugin/types.js.map +1 -0
- package/lib/module/web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.js +42 -0
- package/lib/module/web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.js.map +1 -0
- package/lib/module/web/pmPlugins/ShortcutPlugin.js +123 -0
- package/lib/module/web/pmPlugins/ShortcutPlugin.js.map +1 -0
- package/lib/module/web/pmPlugins/StrictMarksPlugin.js +98 -0
- package/lib/module/web/pmPlugins/StrictMarksPlugin.js.map +1 -0
- package/lib/module/web/pmPlugins/StripBoldInStyledHeadingsPlugin.js +56 -0
- package/lib/module/web/pmPlugins/StripBoldInStyledHeadingsPlugin.js.map +1 -0
- package/lib/module/web/pmPlugins/StripMarksInCodeBlockPlugin.js +28 -0
- package/lib/module/web/pmPlugins/StripMarksInCodeBlockPlugin.js.map +1 -0
- package/lib/module/web/pmPlugins/StripMarksOnImagePlugin.js +29 -0
- package/lib/module/web/pmPlugins/StripMarksOnImagePlugin.js.map +1 -0
- package/lib/module/web/positionMapping.js +76 -0
- package/lib/module/web/positionMapping.js.map +1 -0
- package/lib/module/web/returnKeyTypeToEnterKeyHint.js +20 -0
- package/lib/module/web/returnKeyTypeToEnterKeyHint.js.map +1 -0
- package/lib/module/web/styleConversion/buildMentionRulesCSS.js +33 -0
- package/lib/module/web/styleConversion/buildMentionRulesCSS.js.map +1 -0
- package/lib/module/web/styleConversion/enrichedInputStyleToCSSProperties.js +159 -0
- package/lib/module/web/styleConversion/enrichedInputStyleToCSSProperties.js.map +1 -0
- package/lib/module/web/styleConversion/enrichedInputThemingToCSSProperties.js +18 -0
- package/lib/module/web/styleConversion/enrichedInputThemingToCSSProperties.js.map +1 -0
- package/lib/module/web/styleConversion/htmlStyleToCSSVariables.js +145 -0
- package/lib/module/web/styleConversion/htmlStyleToCSSVariables.js.map +1 -0
- package/lib/module/web/styleConversion/mentionIndicatorCssKey.js +15 -0
- package/lib/module/web/styleConversion/mentionIndicatorCssKey.js.map +1 -0
- package/lib/module/web/styleConversion/toColor.js +18 -0
- package/lib/module/web/styleConversion/toColor.js.map +1 -0
- package/lib/module/web/tiptapHtmlNormalizer.js +30 -0
- package/lib/module/web/tiptapHtmlNormalizer.js.map +1 -0
- package/lib/module/web/useOnChangeHtml.js +8 -0
- package/lib/module/web/useOnChangeHtml.js.map +1 -0
- package/lib/module/web/useOnChangeState.js +88 -0
- package/lib/module/web/useOnChangeState.js.map +1 -0
- package/lib/module/web/useOnChangeText.js +11 -0
- package/lib/module/web/useOnChangeText.js.map +1 -0
- package/lib/module/web/useOnEditorChange.js +25 -0
- package/lib/module/web/useOnEditorChange.js.map +1 -0
- package/lib/module/web/useOnLinkDetected.js +68 -0
- package/lib/module/web/useOnLinkDetected.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/index.native.d.ts +5 -0
- package/lib/typescript/src/index.native.d.ts.map +1 -0
- package/lib/typescript/src/native/EnrichedText.d.ts +3 -0
- package/lib/typescript/src/native/EnrichedText.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 +405 -0
- package/lib/typescript/src/spec/EnrichedTextInputNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/spec/EnrichedTextNativeComponent.d.ts +88 -0
- package/lib/typescript/src/spec/EnrichedTextNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +721 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/EnrichedTextInputDefaultProps.d.ts +13 -0
- package/lib/typescript/src/utils/EnrichedTextInputDefaultProps.d.ts.map +1 -0
- package/lib/typescript/src/utils/defaultHtmlStyle.d.ts +4 -0
- package/lib/typescript/src/utils/defaultHtmlStyle.d.ts.map +1 -0
- package/lib/typescript/src/utils/expandMentionStylesForIndicators.d.ts +3 -0
- package/lib/typescript/src/utils/expandMentionStylesForIndicators.d.ts.map +1 -0
- package/lib/typescript/src/utils/isMentionStyleRecord.d.ts +3 -0
- package/lib/typescript/src/utils/isMentionStyleRecord.d.ts.map +1 -0
- package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts +6 -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/lib/typescript/src/web/EnrichedTextInput.d.ts +4 -0
- package/lib/typescript/src/web/EnrichedTextInput.d.ts.map +1 -0
- package/lib/typescript/src/web/adaptWebToNativeEvent.d.ts +3 -0
- package/lib/typescript/src/web/adaptWebToNativeEvent.d.ts.map +1 -0
- package/lib/typescript/src/web/checkboxHtmlNormalizer.d.ts +3 -0
- package/lib/typescript/src/web/checkboxHtmlNormalizer.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedBlockquote.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedBlockquote.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedBold.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedBold.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedCheckboxItem.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedCheckboxItem.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedCheckboxList.d.ts +9 -0
- package/lib/typescript/src/web/formats/EnrichedCheckboxList.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedCode.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedCode.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedCodeBlock.d.ts +9 -0
- package/lib/typescript/src/web/formats/EnrichedCodeBlock.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedHeading.d.ts +5 -0
- package/lib/typescript/src/web/formats/EnrichedHeading.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedImage.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedImage.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedImageNodeView.d.ts +3 -0
- package/lib/typescript/src/web/formats/EnrichedImageNodeView.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedItalic.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedItalic.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedLink.d.ts +5 -0
- package/lib/typescript/src/web/formats/EnrichedLink.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedListItem.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedListItem.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedMention.d.ts +4 -0
- package/lib/typescript/src/web/formats/EnrichedMention.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedOrderedList.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedOrderedList.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedStrike.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedStrike.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedUnderline.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedUnderline.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedUnorderedList.d.ts +9 -0
- package/lib/typescript/src/web/formats/EnrichedUnorderedList.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/applyWrappingListToSelection.d.ts +18 -0
- package/lib/typescript/src/web/formats/applyWrappingListToSelection.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/formatRules.d.ts +10 -0
- package/lib/typescript/src/web/formats/formatRules.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/listKeyboard.d.ts +4 -0
- package/lib/typescript/src/web/formats/listKeyboard.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/wrappedBlockKeyboard.d.ts +12 -0
- package/lib/typescript/src/web/formats/wrappedBlockKeyboard.d.ts.map +1 -0
- package/lib/typescript/src/web/pasteImages.d.ts +10 -0
- package/lib/typescript/src/web/pasteImages.d.ts.map +1 -0
- package/lib/typescript/src/web/pastedImageDimensions.d.ts +9 -0
- package/lib/typescript/src/web/pastedImageDimensions.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/index.d.ts +9 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/index.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/isCaretInBlockedContext.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/isCaretInBlockedContext.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/makeMentionPluginState.d.ts +4 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/makeMentionPluginState.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/mentionPluginKey.d.ts +4 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/mentionPluginKey.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/removeMentionMarksIfSpansResized.d.ts +9 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/removeMentionMarksIfSpansResized.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/setMention.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/setMention.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/startMention.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/startMention.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/stripPartialMentionMarks.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/stripPartialMentionMarks.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.d.ts +4 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/types.d.ts +20 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/types.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/ShortcutPlugin.d.ts +7 -0
- package/lib/typescript/src/web/pmPlugins/ShortcutPlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/StrictMarksPlugin.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/StrictMarksPlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.d.ts +10 -0
- package/lib/typescript/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/StripMarksInCodeBlockPlugin.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/StripMarksInCodeBlockPlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/StripMarksOnImagePlugin.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/StripMarksOnImagePlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/positionMapping.d.ts +39 -0
- package/lib/typescript/src/web/positionMapping.d.ts.map +1 -0
- package/lib/typescript/src/web/returnKeyTypeToEnterKeyHint.d.ts +4 -0
- package/lib/typescript/src/web/returnKeyTypeToEnterKeyHint.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/buildMentionRulesCSS.d.ts +3 -0
- package/lib/typescript/src/web/styleConversion/buildMentionRulesCSS.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/enrichedInputStyleToCSSProperties.d.ts +8 -0
- package/lib/typescript/src/web/styleConversion/enrichedInputStyleToCSSProperties.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/enrichedInputThemingToCSSProperties.d.ts +9 -0
- package/lib/typescript/src/web/styleConversion/enrichedInputThemingToCSSProperties.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/htmlStyleToCSSVariables.d.ts +10 -0
- package/lib/typescript/src/web/styleConversion/htmlStyleToCSSVariables.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/mentionIndicatorCssKey.d.ts +3 -0
- package/lib/typescript/src/web/styleConversion/mentionIndicatorCssKey.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/toColor.d.ts +3 -0
- package/lib/typescript/src/web/styleConversion/toColor.d.ts.map +1 -0
- package/lib/typescript/src/web/tiptapHtmlNormalizer.d.ts +3 -0
- package/lib/typescript/src/web/tiptapHtmlNormalizer.d.ts.map +1 -0
- package/lib/typescript/src/web/useOnChangeHtml.d.ts +5 -0
- package/lib/typescript/src/web/useOnChangeHtml.d.ts.map +1 -0
- package/lib/typescript/src/web/useOnChangeState.d.ts +6 -0
- package/lib/typescript/src/web/useOnChangeState.d.ts.map +1 -0
- package/lib/typescript/src/web/useOnChangeText.d.ts +5 -0
- package/lib/typescript/src/web/useOnChangeText.d.ts.map +1 -0
- package/lib/typescript/src/web/useOnEditorChange.d.ts +6 -0
- package/lib/typescript/src/web/useOnEditorChange.d.ts.map +1 -0
- package/lib/typescript/src/web/useOnLinkDetected.d.ts +4 -0
- package/lib/typescript/src/web/useOnLinkDetected.d.ts.map +1 -0
- package/package.json +232 -1
- package/react-native.config.js +16 -0
- package/src/index.native.tsx +34 -0
- package/src/index.tsx +24 -0
- package/src/native/EnrichedText.tsx +115 -0
- package/src/native/EnrichedTextInput.tsx +374 -0
- package/src/spec/EnrichedTextInputNativeComponent.ts +524 -0
- package/src/spec/EnrichedTextNativeComponent.ts +110 -0
- package/src/types.ts +864 -0
- package/src/utils/EnrichedTextInputDefaultProps.ts +16 -0
- package/src/utils/defaultHtmlStyle.ts +83 -0
- package/src/utils/expandMentionStylesForIndicators.ts +19 -0
- package/src/utils/isMentionStyleRecord.ts +22 -0
- package/src/utils/normalizeHtmlStyle.ts +181 -0
- package/src/utils/nullthrows.ts +7 -0
- package/src/utils/regexParser.ts +56 -0
- package/src/web/EnrichedTextInput.css +201 -0
- package/src/web/EnrichedTextInput.tsx +403 -0
- package/src/web/adaptWebToNativeEvent.ts +37 -0
- package/src/web/checkboxHtmlNormalizer.ts +62 -0
- package/src/web/formats/EnrichedBlockquote.ts +36 -0
- package/src/web/formats/EnrichedBold.ts +16 -0
- package/src/web/formats/EnrichedCheckboxItem.ts +35 -0
- package/src/web/formats/EnrichedCheckboxList.ts +47 -0
- package/src/web/formats/EnrichedCode.ts +13 -0
- package/src/web/formats/EnrichedCodeBlock.ts +53 -0
- package/src/web/formats/EnrichedHeading.ts +36 -0
- package/src/web/formats/EnrichedImage.ts +59 -0
- package/src/web/formats/EnrichedImageNodeView.tsx +89 -0
- package/src/web/formats/EnrichedItalic.ts +16 -0
- package/src/web/formats/EnrichedLink.ts +149 -0
- package/src/web/formats/EnrichedListItem.ts +17 -0
- package/src/web/formats/EnrichedMention.ts +55 -0
- package/src/web/formats/EnrichedOrderedList.ts +40 -0
- package/src/web/formats/EnrichedStrike.ts +16 -0
- package/src/web/formats/EnrichedUnderline.ts +16 -0
- package/src/web/formats/EnrichedUnorderedList.ts +50 -0
- package/src/web/formats/applyWrappingListToSelection.ts +76 -0
- package/src/web/formats/formatRules.ts +84 -0
- package/src/web/formats/listKeyboard.ts +58 -0
- package/src/web/formats/wrappedBlockKeyboard.ts +76 -0
- package/src/web/pasteImages.ts +96 -0
- package/src/web/pastedImageDimensions.ts +40 -0
- package/src/web/pmPlugins/MentionPlugin/index.ts +45 -0
- package/src/web/pmPlugins/MentionPlugin/isCaretInBlockedContext.ts +17 -0
- package/src/web/pmPlugins/MentionPlugin/makeMentionPluginState.ts +75 -0
- package/src/web/pmPlugins/MentionPlugin/mentionPluginKey.ts +4 -0
- package/src/web/pmPlugins/MentionPlugin/removeMentionMarksIfSpansResized.ts +68 -0
- package/src/web/pmPlugins/MentionPlugin/setMention.ts +83 -0
- package/src/web/pmPlugins/MentionPlugin/startMention.ts +14 -0
- package/src/web/pmPlugins/MentionPlugin/stripPartialMentionMarks.ts +20 -0
- package/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.ts +105 -0
- package/src/web/pmPlugins/MentionPlugin/types.ts +22 -0
- package/src/web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.ts +57 -0
- package/src/web/pmPlugins/ShortcutPlugin.ts +98 -0
- package/src/web/pmPlugins/StrictMarksPlugin.ts +131 -0
- package/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.ts +79 -0
- package/src/web/pmPlugins/StripMarksInCodeBlockPlugin.ts +34 -0
- package/src/web/pmPlugins/StripMarksOnImagePlugin.ts +33 -0
- package/src/web/positionMapping.ts +81 -0
- package/src/web/returnKeyTypeToEnterKeyHint.ts +29 -0
- package/src/web/styleConversion/buildMentionRulesCSS.ts +42 -0
- package/src/web/styleConversion/enrichedInputStyleToCSSProperties.ts +224 -0
- package/src/web/styleConversion/enrichedInputThemingToCSSProperties.ts +34 -0
- package/src/web/styleConversion/htmlStyleToCSSVariables.ts +226 -0
- package/src/web/styleConversion/mentionIndicatorCssKey.ts +14 -0
- package/src/web/styleConversion/toColor.ts +17 -0
- package/src/web/tiptapHtmlNormalizer.ts +33 -0
- package/src/web/useOnChangeHtml.ts +14 -0
- package/src/web/useOnChangeState.ts +125 -0
- package/src/web/useOnChangeText.ts +15 -0
- package/src/web/useOnEditorChange.ts +33 -0
- package/src/web/useOnLinkDetected.ts +82 -0
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
#import "EnrichedTextView.h"
|
|
2
|
+
#import "AttachmentLayoutUtils.h"
|
|
3
|
+
#import "EnrichedTextStyleHeaders.h"
|
|
4
|
+
#import "EnrichedTextTextView.h"
|
|
5
|
+
#import "EnrichedTextTouchHandler.h"
|
|
6
|
+
#import "LayoutManagerExtension.h"
|
|
7
|
+
#import "LinkData.h"
|
|
8
|
+
#import "MentionParams.h"
|
|
9
|
+
#import "MentionStyleProps.h"
|
|
10
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
11
|
+
#import "StringExtension.h"
|
|
12
|
+
#import "StyleUtils.h"
|
|
13
|
+
#import "TextDecorationLineEnum.h"
|
|
14
|
+
#import "TextHtmlParser.h"
|
|
15
|
+
#import <React/RCTConversions.h>
|
|
16
|
+
#import <ReactNativeEnrichedHtml/EnrichedTextComponentDescriptor.h>
|
|
17
|
+
#import <ReactNativeEnrichedHtml/EventEmitters.h>
|
|
18
|
+
#import <ReactNativeEnrichedHtml/Props.h>
|
|
19
|
+
#import <folly/dynamic.h>
|
|
20
|
+
#import <react/utils/ManagedObjectWrapper.h>
|
|
21
|
+
|
|
22
|
+
using namespace facebook::react;
|
|
23
|
+
|
|
24
|
+
@interface EnrichedTextView () <NSObject>
|
|
25
|
+
@end
|
|
26
|
+
|
|
27
|
+
@implementation EnrichedTextView {
|
|
28
|
+
EnrichedTextViewShadowNode::ConcreteState::Shared _state;
|
|
29
|
+
NSMutableDictionary<NSValue *, UIImageView *> *_attachmentViews;
|
|
30
|
+
EnrichedTextTouchHandler *_touchHandler;
|
|
31
|
+
TextHtmlParser *_textParser;
|
|
32
|
+
NSString *_content;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@synthesize blockEmitting = _blockEmitting;
|
|
36
|
+
|
|
37
|
+
// MARK: - Component utils
|
|
38
|
+
|
|
39
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
40
|
+
return concreteComponentDescriptorProvider<EnrichedTextComponentDescriptor>();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Class<RCTComponentViewProtocol> EnrichedTextViewCls(void) {
|
|
44
|
+
return EnrichedTextView.class;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
+ (BOOL)shouldBeRecycled {
|
|
48
|
+
return NO;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// MARK: - Init
|
|
52
|
+
|
|
53
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
54
|
+
if (self = [super initWithFrame:frame]) {
|
|
55
|
+
static const auto defaultProps =
|
|
56
|
+
std::make_shared<const EnrichedTextViewProps>();
|
|
57
|
+
_props = defaultProps;
|
|
58
|
+
_attachmentViews = [[NSMutableDictionary alloc] init];
|
|
59
|
+
defaultTypingAttributes = [[NSMutableDictionary alloc] init];
|
|
60
|
+
_textParser = [[TextHtmlParser alloc] initWithView:self];
|
|
61
|
+
[self setupTextView];
|
|
62
|
+
[self setupStyles];
|
|
63
|
+
self.contentView = textView;
|
|
64
|
+
}
|
|
65
|
+
return self;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (void)setupTextView {
|
|
69
|
+
EnrichedTextTextView *tv = [[EnrichedTextTextView alloc] init];
|
|
70
|
+
_touchHandler = [[EnrichedTextTouchHandler alloc] initWithView:self];
|
|
71
|
+
tv.touchHandler = _touchHandler;
|
|
72
|
+
tv.host = self;
|
|
73
|
+
textView = tv;
|
|
74
|
+
|
|
75
|
+
textView.backgroundColor = UIColor.clearColor;
|
|
76
|
+
textView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
|
77
|
+
textView.textContainer.lineFragmentPadding = 0;
|
|
78
|
+
textView.editable = NO;
|
|
79
|
+
textView.scrollEnabled = NO;
|
|
80
|
+
textView.adjustsFontForContentSizeCategory = YES;
|
|
81
|
+
textView.layoutManager.input = self;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
- (void)setupStyles {
|
|
85
|
+
stylesDict = [StyleUtils stylesDictForHost:self isInput:NO];
|
|
86
|
+
conflictingStyles = [[StyleUtils conflictMap] mutableCopy];
|
|
87
|
+
blockingStyles = [[StyleUtils blockingMap] mutableCopy];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// MARK: - EnrichedViewHost protocol
|
|
91
|
+
|
|
92
|
+
- (UITextView *)textView {
|
|
93
|
+
return textView;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
- (EnrichedConfig *)config {
|
|
97
|
+
return config;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (NSDictionary<NSNumber *, id> *)stylesDict {
|
|
101
|
+
return stylesDict;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
- (NSMutableDictionary<NSNumber *, NSArray<NSNumber *> *> *)conflictingStyles {
|
|
105
|
+
return conflictingStyles;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
- (NSMutableDictionary<NSNumber *, NSArray<NSNumber *> *> *)blockingStyles {
|
|
109
|
+
return blockingStyles;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
- (NSMutableDictionary<NSAttributedStringKey, id> *)defaultTypingAttributes {
|
|
113
|
+
return defaultTypingAttributes;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// MARK: - Props
|
|
117
|
+
|
|
118
|
+
- (void)updateProps:(Props::Shared const &)props
|
|
119
|
+
oldProps:(Props::Shared const &)oldProps {
|
|
120
|
+
const auto &oldViewProps =
|
|
121
|
+
*std::static_pointer_cast<EnrichedTextViewProps const>(_props);
|
|
122
|
+
const auto &newViewProps =
|
|
123
|
+
*std::static_pointer_cast<EnrichedTextViewProps const>(props);
|
|
124
|
+
BOOL isFirstMount = NO;
|
|
125
|
+
BOOL stylePropChanged = NO;
|
|
126
|
+
BOOL textChanged = NO;
|
|
127
|
+
|
|
128
|
+
if (config == nullptr) {
|
|
129
|
+
isFirstMount = YES;
|
|
130
|
+
config = [[EnrichedConfig alloc] init];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
EnrichedConfig *newConfig = [config copy];
|
|
134
|
+
|
|
135
|
+
// color
|
|
136
|
+
if (newViewProps.color != oldViewProps.color) {
|
|
137
|
+
if (isColorMeaningful(newViewProps.color)) {
|
|
138
|
+
UIColor *uiColor = RCTUIColorFromSharedColor(newViewProps.color);
|
|
139
|
+
[newConfig setPrimaryColor:uiColor];
|
|
140
|
+
} else {
|
|
141
|
+
[newConfig setPrimaryColor:nullptr];
|
|
142
|
+
}
|
|
143
|
+
stylePropChanged = YES;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// fontSize
|
|
147
|
+
if (newViewProps.fontSize != oldViewProps.fontSize) {
|
|
148
|
+
if (newViewProps.fontSize) {
|
|
149
|
+
NSNumber *fontSize = @(newViewProps.fontSize);
|
|
150
|
+
[newConfig setPrimaryFontSize:fontSize];
|
|
151
|
+
} else {
|
|
152
|
+
[newConfig setPrimaryFontSize:nullptr];
|
|
153
|
+
}
|
|
154
|
+
stylePropChanged = YES;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// fontWeight
|
|
158
|
+
if (newViewProps.fontWeight != oldViewProps.fontWeight) {
|
|
159
|
+
if (!newViewProps.fontWeight.empty()) {
|
|
160
|
+
[newConfig
|
|
161
|
+
setPrimaryFontWeight:[NSString
|
|
162
|
+
fromCppString:newViewProps.fontWeight]];
|
|
163
|
+
} else {
|
|
164
|
+
[newConfig setPrimaryFontWeight:nullptr];
|
|
165
|
+
}
|
|
166
|
+
stylePropChanged = YES;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// fontFamily
|
|
170
|
+
if (newViewProps.fontFamily != oldViewProps.fontFamily) {
|
|
171
|
+
if (!newViewProps.fontFamily.empty()) {
|
|
172
|
+
[newConfig
|
|
173
|
+
setPrimaryFontFamily:[NSString
|
|
174
|
+
fromCppString:newViewProps.fontFamily]];
|
|
175
|
+
} else {
|
|
176
|
+
[newConfig setPrimaryFontFamily:nullptr];
|
|
177
|
+
}
|
|
178
|
+
stylePropChanged = YES;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// fontStyle
|
|
182
|
+
if (newViewProps.fontStyle != oldViewProps.fontStyle) {
|
|
183
|
+
// TODO: Implement fontStyle setter on EnrichedConfig
|
|
184
|
+
// stylePropChanged = YES;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// htmlStyle headings
|
|
188
|
+
if (newViewProps.htmlStyle.h1.fontSize !=
|
|
189
|
+
oldViewProps.htmlStyle.h1.fontSize) {
|
|
190
|
+
[newConfig setH1FontSize:newViewProps.htmlStyle.h1.fontSize];
|
|
191
|
+
stylePropChanged = YES;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (newViewProps.htmlStyle.h1.bold != oldViewProps.htmlStyle.h1.bold) {
|
|
195
|
+
[newConfig setH1Bold:newViewProps.htmlStyle.h1.bold];
|
|
196
|
+
|
|
197
|
+
// Update style blocks and conflicts for bold
|
|
198
|
+
if (newViewProps.htmlStyle.h1.bold) {
|
|
199
|
+
[StyleUtils addStyleBlock:H1 to:Bold forHost:self];
|
|
200
|
+
[StyleUtils addStyleConflict:Bold to:H1 forHost:self];
|
|
201
|
+
} else {
|
|
202
|
+
[StyleUtils removeStyleBlock:H1 from:Bold forHost:self];
|
|
203
|
+
[StyleUtils removeStyleConflict:Bold from:H1 forHost:self];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
stylePropChanged = YES;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (newViewProps.htmlStyle.h2.fontSize !=
|
|
210
|
+
oldViewProps.htmlStyle.h2.fontSize) {
|
|
211
|
+
[newConfig setH2FontSize:newViewProps.htmlStyle.h2.fontSize];
|
|
212
|
+
stylePropChanged = YES;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (newViewProps.htmlStyle.h2.bold != oldViewProps.htmlStyle.h2.bold) {
|
|
216
|
+
[newConfig setH2Bold:newViewProps.htmlStyle.h2.bold];
|
|
217
|
+
|
|
218
|
+
// Update style blocks and conflicts for bold
|
|
219
|
+
if (newViewProps.htmlStyle.h2.bold) {
|
|
220
|
+
[StyleUtils addStyleBlock:H2 to:Bold forHost:self];
|
|
221
|
+
[StyleUtils addStyleConflict:Bold to:H2 forHost:self];
|
|
222
|
+
} else {
|
|
223
|
+
[StyleUtils removeStyleBlock:H2 from:Bold forHost:self];
|
|
224
|
+
[StyleUtils removeStyleConflict:Bold from:H2 forHost:self];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
stylePropChanged = YES;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (newViewProps.htmlStyle.h3.fontSize !=
|
|
231
|
+
oldViewProps.htmlStyle.h3.fontSize) {
|
|
232
|
+
[newConfig setH3FontSize:newViewProps.htmlStyle.h3.fontSize];
|
|
233
|
+
stylePropChanged = YES;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (newViewProps.htmlStyle.h3.bold != oldViewProps.htmlStyle.h3.bold) {
|
|
237
|
+
[newConfig setH3Bold:newViewProps.htmlStyle.h3.bold];
|
|
238
|
+
|
|
239
|
+
// Update style blocks and conflicts for bold
|
|
240
|
+
if (newViewProps.htmlStyle.h3.bold) {
|
|
241
|
+
[StyleUtils addStyleBlock:H3 to:Bold forHost:self];
|
|
242
|
+
[StyleUtils addStyleConflict:Bold to:H3 forHost:self];
|
|
243
|
+
} else {
|
|
244
|
+
[StyleUtils removeStyleBlock:H3 from:Bold forHost:self];
|
|
245
|
+
[StyleUtils removeStyleConflict:Bold from:H3 forHost:self];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
stylePropChanged = YES;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (newViewProps.htmlStyle.h4.fontSize !=
|
|
252
|
+
oldViewProps.htmlStyle.h4.fontSize) {
|
|
253
|
+
[newConfig setH4FontSize:newViewProps.htmlStyle.h4.fontSize];
|
|
254
|
+
stylePropChanged = YES;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (newViewProps.htmlStyle.h4.bold != oldViewProps.htmlStyle.h4.bold) {
|
|
258
|
+
[newConfig setH4Bold:newViewProps.htmlStyle.h4.bold];
|
|
259
|
+
|
|
260
|
+
// Update style blocks and conflicts for bold
|
|
261
|
+
if (newViewProps.htmlStyle.h4.bold) {
|
|
262
|
+
[StyleUtils addStyleBlock:H4 to:Bold forHost:self];
|
|
263
|
+
[StyleUtils addStyleConflict:Bold to:H4 forHost:self];
|
|
264
|
+
} else {
|
|
265
|
+
[StyleUtils removeStyleBlock:H4 from:Bold forHost:self];
|
|
266
|
+
[StyleUtils removeStyleConflict:Bold from:H4 forHost:self];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
stylePropChanged = YES;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (newViewProps.htmlStyle.h5.fontSize !=
|
|
273
|
+
oldViewProps.htmlStyle.h5.fontSize) {
|
|
274
|
+
[newConfig setH5FontSize:newViewProps.htmlStyle.h5.fontSize];
|
|
275
|
+
stylePropChanged = YES;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (newViewProps.htmlStyle.h5.bold != oldViewProps.htmlStyle.h5.bold) {
|
|
279
|
+
[newConfig setH5Bold:newViewProps.htmlStyle.h5.bold];
|
|
280
|
+
|
|
281
|
+
// Update style blocks and conflicts for bold
|
|
282
|
+
if (newViewProps.htmlStyle.h5.bold) {
|
|
283
|
+
[StyleUtils addStyleBlock:H5 to:Bold forHost:self];
|
|
284
|
+
[StyleUtils addStyleConflict:Bold to:H5 forHost:self];
|
|
285
|
+
} else {
|
|
286
|
+
[StyleUtils removeStyleBlock:H5 from:Bold forHost:self];
|
|
287
|
+
[StyleUtils removeStyleConflict:Bold from:H5 forHost:self];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
stylePropChanged = YES;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (newViewProps.htmlStyle.h6.fontSize !=
|
|
294
|
+
oldViewProps.htmlStyle.h6.fontSize) {
|
|
295
|
+
[newConfig setH6FontSize:newViewProps.htmlStyle.h6.fontSize];
|
|
296
|
+
stylePropChanged = YES;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (newViewProps.htmlStyle.h6.bold != oldViewProps.htmlStyle.h6.bold) {
|
|
300
|
+
[newConfig setH6Bold:newViewProps.htmlStyle.h6.bold];
|
|
301
|
+
|
|
302
|
+
// Update style blocks and conflicts for bold
|
|
303
|
+
if (newViewProps.htmlStyle.h6.bold) {
|
|
304
|
+
[StyleUtils addStyleBlock:H6 to:Bold forHost:self];
|
|
305
|
+
[StyleUtils addStyleConflict:Bold to:H6 forHost:self];
|
|
306
|
+
} else {
|
|
307
|
+
[StyleUtils removeStyleBlock:H6 from:Bold forHost:self];
|
|
308
|
+
[StyleUtils removeStyleConflict:Bold from:H6 forHost:self];
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
stylePropChanged = YES;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// blockquote
|
|
315
|
+
if (newViewProps.htmlStyle.blockquote.borderColor !=
|
|
316
|
+
oldViewProps.htmlStyle.blockquote.borderColor) {
|
|
317
|
+
if (isColorMeaningful(newViewProps.htmlStyle.blockquote.borderColor)) {
|
|
318
|
+
[newConfig setBlockquoteBorderColor:RCTUIColorFromSharedColor(
|
|
319
|
+
newViewProps.htmlStyle.blockquote
|
|
320
|
+
.borderColor)];
|
|
321
|
+
stylePropChanged = YES;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (newViewProps.htmlStyle.blockquote.borderWidth !=
|
|
325
|
+
oldViewProps.htmlStyle.blockquote.borderWidth) {
|
|
326
|
+
[newConfig
|
|
327
|
+
setBlockquoteBorderWidth:newViewProps.htmlStyle.blockquote.borderWidth];
|
|
328
|
+
stylePropChanged = YES;
|
|
329
|
+
}
|
|
330
|
+
if (newViewProps.htmlStyle.blockquote.gapWidth !=
|
|
331
|
+
oldViewProps.htmlStyle.blockquote.gapWidth) {
|
|
332
|
+
[newConfig
|
|
333
|
+
setBlockquoteGapWidth:newViewProps.htmlStyle.blockquote.gapWidth];
|
|
334
|
+
stylePropChanged = YES;
|
|
335
|
+
}
|
|
336
|
+
if (newViewProps.htmlStyle.blockquote.color !=
|
|
337
|
+
oldViewProps.htmlStyle.blockquote.color ||
|
|
338
|
+
isFirstMount) {
|
|
339
|
+
if (isColorMeaningful(newViewProps.htmlStyle.blockquote.color)) {
|
|
340
|
+
[newConfig
|
|
341
|
+
setBlockquoteColor:RCTUIColorFromSharedColor(
|
|
342
|
+
newViewProps.htmlStyle.blockquote.color)];
|
|
343
|
+
} else {
|
|
344
|
+
[newConfig setBlockquoteColor:[newConfig primaryColor]];
|
|
345
|
+
}
|
|
346
|
+
stylePropChanged = YES;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// inline code
|
|
350
|
+
if (newViewProps.htmlStyle.code.color != oldViewProps.htmlStyle.code.color) {
|
|
351
|
+
if (isColorMeaningful(newViewProps.htmlStyle.code.color)) {
|
|
352
|
+
[newConfig setInlineCodeFgColor:RCTUIColorFromSharedColor(
|
|
353
|
+
newViewProps.htmlStyle.code.color)];
|
|
354
|
+
stylePropChanged = YES;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (newViewProps.htmlStyle.code.backgroundColor !=
|
|
358
|
+
oldViewProps.htmlStyle.code.backgroundColor) {
|
|
359
|
+
if (isColorMeaningful(newViewProps.htmlStyle.code.backgroundColor)) {
|
|
360
|
+
[newConfig setInlineCodeBgColor:RCTUIColorFromSharedColor(
|
|
361
|
+
newViewProps.htmlStyle.code
|
|
362
|
+
.backgroundColor)];
|
|
363
|
+
stylePropChanged = YES;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// codeblock
|
|
368
|
+
if (newViewProps.htmlStyle.codeblock.color !=
|
|
369
|
+
oldViewProps.htmlStyle.codeblock.color) {
|
|
370
|
+
if (isColorMeaningful(newViewProps.htmlStyle.codeblock.color)) {
|
|
371
|
+
[newConfig
|
|
372
|
+
setCodeBlockFgColor:RCTUIColorFromSharedColor(
|
|
373
|
+
newViewProps.htmlStyle.codeblock.color)];
|
|
374
|
+
stylePropChanged = YES;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (newViewProps.htmlStyle.codeblock.backgroundColor !=
|
|
378
|
+
oldViewProps.htmlStyle.codeblock.backgroundColor) {
|
|
379
|
+
if (isColorMeaningful(newViewProps.htmlStyle.codeblock.backgroundColor)) {
|
|
380
|
+
[newConfig setCodeBlockBgColor:RCTUIColorFromSharedColor(
|
|
381
|
+
newViewProps.htmlStyle.codeblock
|
|
382
|
+
.backgroundColor)];
|
|
383
|
+
stylePropChanged = YES;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (newViewProps.htmlStyle.codeblock.borderRadius !=
|
|
387
|
+
oldViewProps.htmlStyle.codeblock.borderRadius) {
|
|
388
|
+
[newConfig
|
|
389
|
+
setCodeBlockBorderRadius:newViewProps.htmlStyle.codeblock.borderRadius];
|
|
390
|
+
stylePropChanged = YES;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// ordered list
|
|
394
|
+
if (newViewProps.htmlStyle.ol.gapWidth !=
|
|
395
|
+
oldViewProps.htmlStyle.ol.gapWidth) {
|
|
396
|
+
[newConfig setOrderedListGapWidth:newViewProps.htmlStyle.ol.gapWidth];
|
|
397
|
+
stylePropChanged = YES;
|
|
398
|
+
}
|
|
399
|
+
if (newViewProps.htmlStyle.ol.marginLeft !=
|
|
400
|
+
oldViewProps.htmlStyle.ol.marginLeft) {
|
|
401
|
+
[newConfig setOrderedListMarginLeft:newViewProps.htmlStyle.ol.marginLeft];
|
|
402
|
+
stylePropChanged = YES;
|
|
403
|
+
}
|
|
404
|
+
if (newViewProps.htmlStyle.ol.markerFontWeight !=
|
|
405
|
+
oldViewProps.htmlStyle.ol.markerFontWeight ||
|
|
406
|
+
isFirstMount) {
|
|
407
|
+
if (!newViewProps.htmlStyle.ol.markerFontWeight.empty()) {
|
|
408
|
+
[newConfig
|
|
409
|
+
setOrderedListMarkerFontWeight:
|
|
410
|
+
[NSString
|
|
411
|
+
fromCppString:newViewProps.htmlStyle.ol.markerFontWeight]];
|
|
412
|
+
} else {
|
|
413
|
+
[newConfig setOrderedListMarkerFontWeight:[newConfig primaryFontWeight]];
|
|
414
|
+
}
|
|
415
|
+
stylePropChanged = YES;
|
|
416
|
+
}
|
|
417
|
+
if (newViewProps.htmlStyle.ol.markerColor !=
|
|
418
|
+
oldViewProps.htmlStyle.ol.markerColor ||
|
|
419
|
+
isFirstMount) {
|
|
420
|
+
if (isColorMeaningful(newViewProps.htmlStyle.ol.markerColor)) {
|
|
421
|
+
[newConfig
|
|
422
|
+
setOrderedListMarkerColor:RCTUIColorFromSharedColor(
|
|
423
|
+
newViewProps.htmlStyle.ol.markerColor)];
|
|
424
|
+
} else {
|
|
425
|
+
[newConfig setOrderedListMarkerColor:[newConfig primaryColor]];
|
|
426
|
+
}
|
|
427
|
+
stylePropChanged = YES;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// unordered list
|
|
431
|
+
if (newViewProps.htmlStyle.ul.bulletColor !=
|
|
432
|
+
oldViewProps.htmlStyle.ul.bulletColor) {
|
|
433
|
+
if (isColorMeaningful(newViewProps.htmlStyle.ul.bulletColor)) {
|
|
434
|
+
[newConfig setUnorderedListBulletColor:RCTUIColorFromSharedColor(
|
|
435
|
+
newViewProps.htmlStyle.ul
|
|
436
|
+
.bulletColor)];
|
|
437
|
+
stylePropChanged = YES;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (newViewProps.htmlStyle.ul.bulletSize !=
|
|
441
|
+
oldViewProps.htmlStyle.ul.bulletSize) {
|
|
442
|
+
[newConfig setUnorderedListBulletSize:newViewProps.htmlStyle.ul.bulletSize];
|
|
443
|
+
stylePropChanged = YES;
|
|
444
|
+
}
|
|
445
|
+
if (newViewProps.htmlStyle.ul.gapWidth !=
|
|
446
|
+
oldViewProps.htmlStyle.ul.gapWidth) {
|
|
447
|
+
[newConfig setUnorderedListGapWidth:newViewProps.htmlStyle.ul.gapWidth];
|
|
448
|
+
stylePropChanged = YES;
|
|
449
|
+
}
|
|
450
|
+
if (newViewProps.htmlStyle.ul.marginLeft !=
|
|
451
|
+
oldViewProps.htmlStyle.ul.marginLeft) {
|
|
452
|
+
[newConfig setUnorderedListMarginLeft:newViewProps.htmlStyle.ul.marginLeft];
|
|
453
|
+
stylePropChanged = YES;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// link
|
|
457
|
+
if (newViewProps.htmlStyle.a.color != oldViewProps.htmlStyle.a.color) {
|
|
458
|
+
if (isColorMeaningful(newViewProps.htmlStyle.a.color)) {
|
|
459
|
+
[newConfig setLinkColor:RCTUIColorFromSharedColor(
|
|
460
|
+
newViewProps.htmlStyle.a.color)];
|
|
461
|
+
stylePropChanged = YES;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (newViewProps.htmlStyle.a.pressColor !=
|
|
465
|
+
oldViewProps.htmlStyle.a.pressColor) {
|
|
466
|
+
if (isColorMeaningful(newViewProps.htmlStyle.a.pressColor)) {
|
|
467
|
+
[newConfig setLinkPressColor:RCTUIColorFromSharedColor(
|
|
468
|
+
newViewProps.htmlStyle.a.pressColor)];
|
|
469
|
+
stylePropChanged = YES;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (newViewProps.htmlStyle.a.textDecorationLine !=
|
|
473
|
+
oldViewProps.htmlStyle.a.textDecorationLine) {
|
|
474
|
+
NSString *objcString =
|
|
475
|
+
[NSString fromCppString:newViewProps.htmlStyle.a.textDecorationLine];
|
|
476
|
+
if ([objcString isEqualToString:DecorationUnderline]) {
|
|
477
|
+
[newConfig setLinkDecorationLine:DecorationUnderline];
|
|
478
|
+
} else {
|
|
479
|
+
[newConfig setLinkDecorationLine:DecorationNone];
|
|
480
|
+
}
|
|
481
|
+
stylePropChanged = YES;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// checkbox list
|
|
485
|
+
if (newViewProps.htmlStyle.ulCheckbox.boxSize !=
|
|
486
|
+
oldViewProps.htmlStyle.ulCheckbox.boxSize) {
|
|
487
|
+
[newConfig
|
|
488
|
+
setCheckboxListBoxSize:newViewProps.htmlStyle.ulCheckbox.boxSize];
|
|
489
|
+
stylePropChanged = YES;
|
|
490
|
+
}
|
|
491
|
+
if (newViewProps.htmlStyle.ulCheckbox.gapWidth !=
|
|
492
|
+
oldViewProps.htmlStyle.ulCheckbox.gapWidth) {
|
|
493
|
+
[newConfig
|
|
494
|
+
setCheckboxListGapWidth:newViewProps.htmlStyle.ulCheckbox.gapWidth];
|
|
495
|
+
stylePropChanged = YES;
|
|
496
|
+
}
|
|
497
|
+
if (newViewProps.htmlStyle.ulCheckbox.marginLeft !=
|
|
498
|
+
oldViewProps.htmlStyle.ulCheckbox.marginLeft) {
|
|
499
|
+
[newConfig
|
|
500
|
+
setCheckboxListMarginLeft:newViewProps.htmlStyle.ulCheckbox.marginLeft];
|
|
501
|
+
stylePropChanged = YES;
|
|
502
|
+
}
|
|
503
|
+
if (newViewProps.htmlStyle.ulCheckbox.boxColor !=
|
|
504
|
+
oldViewProps.htmlStyle.ulCheckbox.boxColor) {
|
|
505
|
+
if (isColorMeaningful(newViewProps.htmlStyle.ulCheckbox.boxColor)) {
|
|
506
|
+
[newConfig setCheckboxListBoxColor:RCTUIColorFromSharedColor(
|
|
507
|
+
newViewProps.htmlStyle.ulCheckbox
|
|
508
|
+
.boxColor)];
|
|
509
|
+
stylePropChanged = YES;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// mention
|
|
514
|
+
folly::dynamic oldMentionStyle = oldViewProps.htmlStyle.mention;
|
|
515
|
+
folly::dynamic newMentionStyle = newViewProps.htmlStyle.mention;
|
|
516
|
+
if (oldMentionStyle != newMentionStyle) {
|
|
517
|
+
bool newSingleProps = NO;
|
|
518
|
+
|
|
519
|
+
for (const auto &obj : newMentionStyle.items()) {
|
|
520
|
+
if (obj.second.isInt() || obj.second.isString()) {
|
|
521
|
+
newSingleProps = YES;
|
|
522
|
+
break;
|
|
523
|
+
} else if (obj.second.isObject()) {
|
|
524
|
+
newSingleProps = NO;
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (newSingleProps) {
|
|
530
|
+
[newConfig setMentionStyleProps:
|
|
531
|
+
[MentionStyleProps
|
|
532
|
+
getSinglePropsFromFollyDynamic:newMentionStyle]];
|
|
533
|
+
} else {
|
|
534
|
+
[newConfig setMentionStyleProps:
|
|
535
|
+
[MentionStyleProps
|
|
536
|
+
getComplexPropsFromFollyDynamic:newMentionStyle]];
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
stylePropChanged = YES;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// text prop
|
|
543
|
+
if (newViewProps.text != oldViewProps.text || isFirstMount) {
|
|
544
|
+
textChanged = YES;
|
|
545
|
+
_content = [NSString fromCppString:newViewProps.text];
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// ellipsizeMode
|
|
549
|
+
if (newViewProps.ellipsizeMode != oldViewProps.ellipsizeMode ||
|
|
550
|
+
isFirstMount) {
|
|
551
|
+
NSString *mode = [NSString fromCppString:newViewProps.ellipsizeMode];
|
|
552
|
+
if ([mode isEqualToString:@"head"]) {
|
|
553
|
+
textView.textContainer.lineBreakMode = NSLineBreakByTruncatingHead;
|
|
554
|
+
} else if ([mode isEqualToString:@"middle"]) {
|
|
555
|
+
textView.textContainer.lineBreakMode = NSLineBreakByTruncatingMiddle;
|
|
556
|
+
} else if ([mode isEqualToString:@"clip"]) {
|
|
557
|
+
textView.textContainer.lineBreakMode = NSLineBreakByClipping;
|
|
558
|
+
} else {
|
|
559
|
+
textView.textContainer.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// numberOfLines
|
|
564
|
+
if (newViewProps.numberOfLines != oldViewProps.numberOfLines ||
|
|
565
|
+
isFirstMount) {
|
|
566
|
+
textView.textContainer.maximumNumberOfLines = newViewProps.numberOfLines;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// selectable
|
|
570
|
+
if (newViewProps.selectable != oldViewProps.selectable || isFirstMount) {
|
|
571
|
+
textView.selectable = newViewProps.selectable;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// selectionColor
|
|
575
|
+
if (newViewProps.selectionColor != oldViewProps.selectionColor) {
|
|
576
|
+
if (isColorMeaningful(newViewProps.selectionColor)) {
|
|
577
|
+
textView.tintColor =
|
|
578
|
+
RCTUIColorFromSharedColor(newViewProps.selectionColor);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// useHtmlNormalizer
|
|
583
|
+
if (newViewProps.useHtmlNormalizer != oldViewProps.useHtmlNormalizer) {
|
|
584
|
+
useHtmlNormalizer = newViewProps.useHtmlNormalizer;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// allowFontScaling
|
|
588
|
+
if (newViewProps.allowFontScaling != oldViewProps.allowFontScaling) {
|
|
589
|
+
[newConfig setAllowFontScaling:newViewProps.allowFontScaling];
|
|
590
|
+
stylePropChanged = YES;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (stylePropChanged) {
|
|
594
|
+
config = newConfig;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
[self syncDefaultTypingAttributesFromConfig];
|
|
598
|
+
|
|
599
|
+
if (textChanged || stylePropChanged) {
|
|
600
|
+
[self renderContent];
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
[super updateProps:props oldProps:oldProps];
|
|
604
|
+
[self tryUpdatingHeight];
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
- (void)syncDefaultTypingAttributesFromConfig {
|
|
608
|
+
defaultTypingAttributes[NSForegroundColorAttributeName] =
|
|
609
|
+
[config primaryColor];
|
|
610
|
+
defaultTypingAttributes[NSFontAttributeName] = [config primaryFont];
|
|
611
|
+
defaultTypingAttributes[NSUnderlineColorAttributeName] =
|
|
612
|
+
[config primaryColor];
|
|
613
|
+
defaultTypingAttributes[NSStrikethroughColorAttributeName] =
|
|
614
|
+
[config primaryColor];
|
|
615
|
+
NSMutableParagraphStyle *pStyle = [[NSMutableParagraphStyle alloc] init];
|
|
616
|
+
pStyle.minimumLineHeight = [config scaledPrimaryLineHeight];
|
|
617
|
+
defaultTypingAttributes[NSParagraphStyleAttributeName] = pStyle;
|
|
618
|
+
textView.typingAttributes = defaultTypingAttributes;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// MARK: - Rendering
|
|
622
|
+
|
|
623
|
+
- (void)renderContent {
|
|
624
|
+
if (_content.length == 0) {
|
|
625
|
+
[textView.textStorage
|
|
626
|
+
setAttributedString:[[NSAttributedString alloc] initWithString:@""]];
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
[_textParser replaceWholeFromHtml:_content];
|
|
630
|
+
[self layoutAttachments];
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// MARK: - Measuring and state
|
|
634
|
+
|
|
635
|
+
- (CGSize)measureSize:(CGFloat)maxWidth {
|
|
636
|
+
if (textView.textStorage.length == 0) {
|
|
637
|
+
return CGSizeMake(maxWidth, 0);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
NSMutableAttributedString *currentStr = [[NSMutableAttributedString alloc]
|
|
641
|
+
initWithAttributedString:textView.textStorage];
|
|
642
|
+
|
|
643
|
+
// edge case: input with only a zero width space should still be of a height
|
|
644
|
+
// of a single line, so we add a mock "I" character
|
|
645
|
+
if ([currentStr length] == 1 &&
|
|
646
|
+
[[currentStr.string substringWithRange:NSMakeRange(0, 1)]
|
|
647
|
+
isEqualToString:@"\u200B"]) {
|
|
648
|
+
[currentStr
|
|
649
|
+
appendAttributedString:[[NSAttributedString alloc]
|
|
650
|
+
initWithString:@"I"
|
|
651
|
+
attributes:defaultTypingAttributes]];
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// edge case: trailing newlines aren't counted towards height calculations, so
|
|
655
|
+
// we add a mock "I" character
|
|
656
|
+
if (currentStr.length > 0) {
|
|
657
|
+
unichar lastChar =
|
|
658
|
+
[currentStr.string characterAtIndex:currentStr.length - 1];
|
|
659
|
+
if ([[NSCharacterSet newlineCharacterSet] characterIsMember:lastChar]) {
|
|
660
|
+
[currentStr
|
|
661
|
+
appendAttributedString:[[NSAttributedString alloc]
|
|
662
|
+
initWithString:@"I"
|
|
663
|
+
attributes:defaultTypingAttributes]];
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// Use TextKit measurement so height respects:
|
|
668
|
+
// - maximumNumberOfLines / lineBreakMode
|
|
669
|
+
// - varying line heights (e.g. headings)
|
|
670
|
+
NSTextStorage *measurementStorage =
|
|
671
|
+
[[NSTextStorage alloc] initWithAttributedString:currentStr];
|
|
672
|
+
NSLayoutManager *measurementLayoutManager = [[NSLayoutManager alloc] init];
|
|
673
|
+
NSTextContainer *measurementContainer =
|
|
674
|
+
[[NSTextContainer alloc] initWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX)];
|
|
675
|
+
measurementContainer.lineFragmentPadding = 0;
|
|
676
|
+
measurementContainer.maximumNumberOfLines =
|
|
677
|
+
textView.textContainer.maximumNumberOfLines;
|
|
678
|
+
measurementContainer.lineBreakMode = textView.textContainer.lineBreakMode;
|
|
679
|
+
[measurementLayoutManager addTextContainer:measurementContainer];
|
|
680
|
+
[measurementStorage addLayoutManager:measurementLayoutManager];
|
|
681
|
+
[measurementLayoutManager ensureLayoutForTextContainer:measurementContainer];
|
|
682
|
+
|
|
683
|
+
CGRect usedRect =
|
|
684
|
+
[measurementLayoutManager usedRectForTextContainer:measurementContainer];
|
|
685
|
+
CGFloat measuredHeight = ceil(usedRect.size.height);
|
|
686
|
+
|
|
687
|
+
return CGSizeMake(maxWidth, measuredHeight);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
- (void)updateState:(State::Shared const &)state
|
|
691
|
+
oldState:(State::Shared const &)oldState {
|
|
692
|
+
_state =
|
|
693
|
+
std::static_pointer_cast<const EnrichedTextViewShadowNode::ConcreteState>(
|
|
694
|
+
state);
|
|
695
|
+
|
|
696
|
+
if (oldState == nullptr) {
|
|
697
|
+
[self tryUpdatingHeight];
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
- (void)tryUpdatingHeight {
|
|
702
|
+
if (_state == nullptr) {
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
auto selfRef = wrapManagedObjectWeakly(self);
|
|
706
|
+
_state->updateState(EnrichedTextViewState(selfRef));
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Handles iOS Dynamic Type changes (user changing font size in System
|
|
711
|
+
* Settings).
|
|
712
|
+
*
|
|
713
|
+
* Unlike Android, iOS Views do not automatically rescale existing
|
|
714
|
+
* NSAttributedStrings when the system font size changes. The text attributes
|
|
715
|
+
* are static once drawn, so we re-parse the HTML to rebuild every run with
|
|
716
|
+
* fonts at the new content size category.
|
|
717
|
+
*/
|
|
718
|
+
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
|
|
719
|
+
[super traitCollectionDidChange:previousTraitCollection];
|
|
720
|
+
|
|
721
|
+
if (!config.allowFontScaling) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
if (previousTraitCollection.preferredContentSizeCategory ==
|
|
726
|
+
self.traitCollection.preferredContentSizeCategory) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
[config invalidateFonts];
|
|
731
|
+
[self syncDefaultTypingAttributesFromConfig];
|
|
732
|
+
[self renderContent];
|
|
733
|
+
[self tryUpdatingHeight];
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
- (std::shared_ptr<EnrichedTextViewEventEmitter>)getEventEmitter {
|
|
737
|
+
if (_eventEmitter != nullptr) {
|
|
738
|
+
auto emitter =
|
|
739
|
+
static_cast<const EnrichedTextViewEventEmitter &>(*_eventEmitter);
|
|
740
|
+
return std::make_shared<EnrichedTextViewEventEmitter>(emitter);
|
|
741
|
+
}
|
|
742
|
+
return nullptr;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
- (void)emitOnLinkPressEvent:(NSString *)url {
|
|
746
|
+
if (!url)
|
|
747
|
+
return;
|
|
748
|
+
auto emitter = [self getEventEmitter];
|
|
749
|
+
if (emitter != nullptr) {
|
|
750
|
+
emitter->onLinkPress({.url = [url toCppString]});
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
- (void)emitOnMentionPressEvent:(MentionParams *)mention {
|
|
755
|
+
auto emitter = [self getEventEmitter];
|
|
756
|
+
if (emitter != nullptr) {
|
|
757
|
+
folly::dynamic attrsObj = folly::dynamic::object;
|
|
758
|
+
if (mention.attributes != nil) {
|
|
759
|
+
NSData *data =
|
|
760
|
+
[mention.attributes dataUsingEncoding:NSUTF8StringEncoding];
|
|
761
|
+
NSError *error = nil;
|
|
762
|
+
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data
|
|
763
|
+
options:0
|
|
764
|
+
error:&error];
|
|
765
|
+
if (error != nil) {
|
|
766
|
+
NSLog(@"[EnrichedTextView] Failed to parse mention attributes JSON: %@",
|
|
767
|
+
error);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
for (NSString *key in dict) {
|
|
772
|
+
id val = dict[key];
|
|
773
|
+
if ([val isKindOfClass:[NSString class]]) {
|
|
774
|
+
attrsObj[[key toCppString]] = [val toCppString];
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
emitter->onMentionPress({
|
|
780
|
+
.text = mention.text ? [mention.text toCppString] : std::string{},
|
|
781
|
+
.indicator =
|
|
782
|
+
mention.indicator ? [mention.indicator toCppString] : std::string{},
|
|
783
|
+
.attributes = attrsObj,
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// MARK: - Media attachments delegate
|
|
789
|
+
|
|
790
|
+
- (void)mediaAttachmentDidUpdate:(MediaAttachment *)attachment {
|
|
791
|
+
[AttachmentLayoutUtils handleAttachmentUpdate:attachment
|
|
792
|
+
textView:textView
|
|
793
|
+
onLayoutBlock:^{
|
|
794
|
+
[self layoutAttachments];
|
|
795
|
+
[self tryUpdatingHeight];
|
|
796
|
+
}];
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
- (void)layoutAttachments {
|
|
800
|
+
_attachmentViews =
|
|
801
|
+
[AttachmentLayoutUtils layoutAttachmentsInTextView:textView
|
|
802
|
+
config:config
|
|
803
|
+
existingViews:_attachmentViews];
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
@end
|