react-native-enriched-html 0.0.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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,371 @@
|
|
|
1
|
+
package com.swmansion.enriched.textinput.styles
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import com.facebook.react.bridge.ColorPropConverter
|
|
5
|
+
import com.facebook.react.bridge.ReactContext
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap
|
|
7
|
+
import com.facebook.react.views.text.ReactTypefaceUtils.parseFontWeight
|
|
8
|
+
import com.swmansion.enriched.common.EnrichedConstants
|
|
9
|
+
import com.swmansion.enriched.common.EnrichedStyle
|
|
10
|
+
import com.swmansion.enriched.common.MentionStyle
|
|
11
|
+
import com.swmansion.enriched.common.pixelFromSpOrDp
|
|
12
|
+
import com.swmansion.enriched.textinput.EnrichedTextInputView
|
|
13
|
+
import kotlin.Float
|
|
14
|
+
import kotlin.Int
|
|
15
|
+
import kotlin.String
|
|
16
|
+
import kotlin.math.ceil
|
|
17
|
+
|
|
18
|
+
class HtmlStyle : EnrichedStyle {
|
|
19
|
+
private var style: ReadableMap? = null
|
|
20
|
+
private var view: EnrichedTextInputView? = null
|
|
21
|
+
|
|
22
|
+
// Default values are ignored as they are specified on the JS side.
|
|
23
|
+
// They are specified only because they are required by the constructor.
|
|
24
|
+
// JS passes them as a prop - so they are initialized after the constructor is called.
|
|
25
|
+
override var h1FontSize: Int = 72
|
|
26
|
+
override var h1Bold: Boolean = false
|
|
27
|
+
|
|
28
|
+
override var h2FontSize: Int = 64
|
|
29
|
+
override var h2Bold: Boolean = false
|
|
30
|
+
|
|
31
|
+
override var h3FontSize: Int = 56
|
|
32
|
+
override var h3Bold: Boolean = false
|
|
33
|
+
|
|
34
|
+
override var h4FontSize: Int = 48
|
|
35
|
+
override var h4Bold: Boolean = false
|
|
36
|
+
|
|
37
|
+
override var h5FontSize: Int = 40
|
|
38
|
+
override var h5Bold: Boolean = false
|
|
39
|
+
|
|
40
|
+
override var h6FontSize: Int = 32
|
|
41
|
+
override var h6Bold: Boolean = false
|
|
42
|
+
|
|
43
|
+
override var blockquoteColor: Int? = null
|
|
44
|
+
override var blockquoteBorderColor: Int = Color.BLACK
|
|
45
|
+
override var blockquoteStripeWidth: Int = 2
|
|
46
|
+
override var blockquoteGapWidth: Int = 16
|
|
47
|
+
|
|
48
|
+
override var olGapWidth: Int = 16
|
|
49
|
+
override var olMarginLeft: Int = 24
|
|
50
|
+
override var olMarkerFontWeight: Int? = null
|
|
51
|
+
override var olMarkerColor: Int? = null
|
|
52
|
+
|
|
53
|
+
override var ulGapWidth: Int = 16
|
|
54
|
+
override var ulMarginLeft: Int = 24
|
|
55
|
+
override var ulBulletSize: Int = 8
|
|
56
|
+
override var ulBulletColor: Int = Color.BLACK
|
|
57
|
+
|
|
58
|
+
override var ulCheckboxBoxSize: Int = 50
|
|
59
|
+
override var ulCheckboxGapWidth: Int = 16
|
|
60
|
+
override var ulCheckboxMarginLeft: Int = 24
|
|
61
|
+
override var ulCheckboxBoxColor: Int = Color.BLACK
|
|
62
|
+
|
|
63
|
+
override var aColor: Int = Color.BLACK
|
|
64
|
+
override var aUnderline: Boolean = true
|
|
65
|
+
|
|
66
|
+
override var codeBlockColor: Int = Color.BLACK
|
|
67
|
+
override var codeBlockBackgroundColor: Int = Color.BLACK
|
|
68
|
+
override var codeBlockRadius: Float = 4f
|
|
69
|
+
|
|
70
|
+
override var inlineCodeColor: Int = Color.BLACK
|
|
71
|
+
override var inlineCodeBackgroundColor: Int = Color.BLACK
|
|
72
|
+
|
|
73
|
+
override var mentionsStyle: MutableMap<String, MentionStyle> = mutableMapOf()
|
|
74
|
+
|
|
75
|
+
constructor(view: EnrichedTextInputView?, style: ReadableMap?) {
|
|
76
|
+
this.view = view
|
|
77
|
+
this.style = style
|
|
78
|
+
|
|
79
|
+
invalidateStyles()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
fun invalidateStyles() {
|
|
83
|
+
val style = this.style ?: return
|
|
84
|
+
|
|
85
|
+
val h1Style = style.getMap("h1")
|
|
86
|
+
h1FontSize = parseFloat(h1Style, "fontSize").toInt()
|
|
87
|
+
h1Bold = h1Style?.getBoolean("bold") == true
|
|
88
|
+
|
|
89
|
+
val h2Style = style.getMap("h2")
|
|
90
|
+
h2FontSize = parseFloat(h2Style, "fontSize").toInt()
|
|
91
|
+
h2Bold = h2Style?.getBoolean("bold") == true
|
|
92
|
+
|
|
93
|
+
val h3Style = style.getMap("h3")
|
|
94
|
+
h3FontSize = parseFloat(h3Style, "fontSize").toInt()
|
|
95
|
+
h3Bold = h3Style?.getBoolean("bold") == true
|
|
96
|
+
|
|
97
|
+
val h4Style = style.getMap("h4")
|
|
98
|
+
h4FontSize = parseFloat(h4Style, "fontSize").toInt()
|
|
99
|
+
h4Bold = h4Style?.getBoolean("bold") == true
|
|
100
|
+
|
|
101
|
+
val h5Style = style.getMap("h5")
|
|
102
|
+
h5FontSize = parseFloat(h5Style, "fontSize").toInt()
|
|
103
|
+
h5Bold = h5Style?.getBoolean("bold") == true
|
|
104
|
+
|
|
105
|
+
val h6Style = style.getMap("h6")
|
|
106
|
+
h6FontSize = parseFloat(h6Style, "fontSize").toInt()
|
|
107
|
+
h6Bold = h6Style?.getBoolean("bold") == true
|
|
108
|
+
|
|
109
|
+
val blockquoteStyle = style.getMap("blockquote")
|
|
110
|
+
blockquoteColor = parseOptionalColor(blockquoteStyle, "color")
|
|
111
|
+
blockquoteBorderColor = parseColor(blockquoteStyle, "borderColor")
|
|
112
|
+
blockquoteGapWidth = parseFloat(blockquoteStyle, "gapWidth").toInt()
|
|
113
|
+
blockquoteStripeWidth = parseFloat(blockquoteStyle, "borderWidth").toInt()
|
|
114
|
+
|
|
115
|
+
val olStyle = style.getMap("ol")
|
|
116
|
+
val userDefinedMarginLeft = parseFloat(olStyle, "marginLeft").toInt()
|
|
117
|
+
val calculatedMarginLeft = calculateOlMarginLeft(view, userDefinedMarginLeft)
|
|
118
|
+
olMarginLeft = calculatedMarginLeft
|
|
119
|
+
olGapWidth = parseFloat(olStyle, "gapWidth").toInt()
|
|
120
|
+
olMarkerColor = parseOptionalColor(olStyle, "markerColor")
|
|
121
|
+
olMarkerFontWeight = parseOptionalFontWeight(olStyle, "markerFontWeight")
|
|
122
|
+
|
|
123
|
+
val ulStyle = style.getMap("ul")
|
|
124
|
+
ulBulletColor = parseColor(ulStyle, "bulletColor")
|
|
125
|
+
ulGapWidth = parseFloat(ulStyle, "gapWidth").toInt()
|
|
126
|
+
ulMarginLeft = parseFloat(ulStyle, "marginLeft").toInt()
|
|
127
|
+
ulBulletSize = parseFloat(ulStyle, "bulletSize").toInt()
|
|
128
|
+
|
|
129
|
+
val ulCheckboxStyle = style.getMap("ulCheckbox")
|
|
130
|
+
ulCheckboxBoxSize = parseFloat(ulCheckboxStyle, "boxSize").toInt()
|
|
131
|
+
ulCheckboxGapWidth = parseFloat(ulCheckboxStyle, "gapWidth").toInt()
|
|
132
|
+
ulCheckboxMarginLeft = parseFloat(ulCheckboxStyle, "marginLeft").toInt()
|
|
133
|
+
ulCheckboxBoxColor = parseColor(ulCheckboxStyle, "boxColor")
|
|
134
|
+
|
|
135
|
+
val aStyle = style.getMap("a")
|
|
136
|
+
aColor = parseColor(aStyle, "color")
|
|
137
|
+
aUnderline = parseIsUnderline(aStyle)
|
|
138
|
+
|
|
139
|
+
val codeBlockStyle = style.getMap("codeblock")
|
|
140
|
+
codeBlockRadius = parseFloat(codeBlockStyle, "borderRadius")
|
|
141
|
+
codeBlockColor = parseColor(codeBlockStyle, "color")
|
|
142
|
+
codeBlockBackgroundColor = parseColorWithOpacity(codeBlockStyle, "backgroundColor", 80)
|
|
143
|
+
|
|
144
|
+
val inlineCodeStyle = style.getMap("code")
|
|
145
|
+
inlineCodeColor = parseColor(inlineCodeStyle, "color")
|
|
146
|
+
inlineCodeBackgroundColor = parseColorWithOpacity(inlineCodeStyle, "backgroundColor", 80)
|
|
147
|
+
|
|
148
|
+
val mentionStyle = style.getMap("mention")
|
|
149
|
+
mentionsStyle = parseMentionsStyle(mentionStyle)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private fun parseFloat(
|
|
153
|
+
map: ReadableMap?,
|
|
154
|
+
key: String,
|
|
155
|
+
): Float {
|
|
156
|
+
val safeMap = ensureValueIsSet(map, key)
|
|
157
|
+
val value = safeMap.getDouble(key)
|
|
158
|
+
return ceil(pixelFromSpOrDp(value, view?.allowFontScaling ?: EnrichedConstants.ALLOW_FONT_SCALING_DEFAULT))
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private fun parseColorWithOpacity(
|
|
162
|
+
map: ReadableMap?,
|
|
163
|
+
key: String,
|
|
164
|
+
opacity: Int,
|
|
165
|
+
): Int {
|
|
166
|
+
val color = parseColor(map, key)
|
|
167
|
+
return withOpacity(color, opacity)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private fun parseOptionalColor(
|
|
171
|
+
map: ReadableMap?,
|
|
172
|
+
key: String,
|
|
173
|
+
): Int? {
|
|
174
|
+
if (map == null) return null
|
|
175
|
+
if (!map.hasKey(key)) return null
|
|
176
|
+
if (map.isNull(key)) return null
|
|
177
|
+
|
|
178
|
+
return parseColor(map, key)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private fun parseColor(
|
|
182
|
+
map: ReadableMap?,
|
|
183
|
+
key: String,
|
|
184
|
+
): Int {
|
|
185
|
+
val safeMap = ensureValueIsSet(map, key)
|
|
186
|
+
|
|
187
|
+
val color = safeMap.getDouble(key)
|
|
188
|
+
val parsedColor = ColorPropConverter.getColor(color, view?.context as ReactContext)
|
|
189
|
+
if (parsedColor == null) {
|
|
190
|
+
throw Error("Specified color value is not supported: $color")
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return parsedColor
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private fun withOpacity(
|
|
197
|
+
color: Int,
|
|
198
|
+
alpha: Int,
|
|
199
|
+
): Int {
|
|
200
|
+
if (Color.alpha(color) != 255) return color
|
|
201
|
+
val a = alpha.coerceIn(0, 255)
|
|
202
|
+
return (color and 0x00FFFFFF) or (a shl 24)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
private fun parseIsUnderline(map: ReadableMap?): Boolean {
|
|
206
|
+
val underline = map?.getString("textDecorationLine")
|
|
207
|
+
val isEnabled = underline == "underline"
|
|
208
|
+
val isDisabled = underline == "none"
|
|
209
|
+
|
|
210
|
+
if (isEnabled) return true
|
|
211
|
+
if (isDisabled) return false
|
|
212
|
+
|
|
213
|
+
throw Error("Specified textDecorationLine value is not supported: $underline. Supported values are 'underline' and 'none'.")
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private fun calculateOlMarginLeft(
|
|
217
|
+
view: EnrichedTextInputView?,
|
|
218
|
+
userMargin: Int,
|
|
219
|
+
): Int {
|
|
220
|
+
val fontSize = view?.fontSize?.toInt() ?: 0
|
|
221
|
+
val leadMargin = fontSize / 2
|
|
222
|
+
|
|
223
|
+
return leadMargin + userMargin
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private fun ensureValueIsSet(
|
|
227
|
+
map: ReadableMap?,
|
|
228
|
+
key: String,
|
|
229
|
+
): ReadableMap {
|
|
230
|
+
if (map == null) throw Error("Style map cannot be null")
|
|
231
|
+
|
|
232
|
+
if (!map.hasKey(key)) throw Error("Style map must contain key: $key")
|
|
233
|
+
|
|
234
|
+
if (map.isNull(key)) throw Error("Style map cannot contain null value for key: $key")
|
|
235
|
+
|
|
236
|
+
return map
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
private fun parseMentionsStyle(mentionsStyle: ReadableMap?): MutableMap<String, MentionStyle> {
|
|
240
|
+
if (mentionsStyle == null) throw Error("Mentions style cannot be null")
|
|
241
|
+
|
|
242
|
+
val parsedMentionsStyle: MutableMap<String, MentionStyle> = mutableMapOf()
|
|
243
|
+
|
|
244
|
+
val iterator = mentionsStyle.keySetIterator()
|
|
245
|
+
while (iterator.hasNextKey()) {
|
|
246
|
+
val key = iterator.nextKey()
|
|
247
|
+
val value = mentionsStyle.getMap(key)
|
|
248
|
+
|
|
249
|
+
if (value == null) throw Error("Mention style for key '$key' cannot be null")
|
|
250
|
+
|
|
251
|
+
val color = parseColor(value, "color")
|
|
252
|
+
val backgroundColor = parseColorWithOpacity(value, "backgroundColor", 80)
|
|
253
|
+
val isUnderline = parseIsUnderline(value)
|
|
254
|
+
val parsedStyle = MentionStyle(color, backgroundColor, isUnderline)
|
|
255
|
+
parsedMentionsStyle.put(key, parsedStyle)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return parsedMentionsStyle
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
private fun parseOptionalFontWeight(
|
|
262
|
+
map: ReadableMap?,
|
|
263
|
+
key: String,
|
|
264
|
+
): Int? {
|
|
265
|
+
if (map == null) return null
|
|
266
|
+
if (!map.hasKey(key)) return null
|
|
267
|
+
if (map.isNull(key)) return null
|
|
268
|
+
|
|
269
|
+
val fontWeight = map.getString(key) ?: return null
|
|
270
|
+
return parseFontWeight(fontWeight)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
override fun equals(other: Any?): Boolean {
|
|
274
|
+
if (this === other) return true
|
|
275
|
+
if (other !is HtmlStyle) return false
|
|
276
|
+
|
|
277
|
+
return h1FontSize == other.h1FontSize &&
|
|
278
|
+
h1Bold == other.h1Bold &&
|
|
279
|
+
h2FontSize == other.h2FontSize &&
|
|
280
|
+
h2Bold == other.h2Bold &&
|
|
281
|
+
h3FontSize == other.h3FontSize &&
|
|
282
|
+
h3Bold == other.h3Bold &&
|
|
283
|
+
h4FontSize == other.h4FontSize &&
|
|
284
|
+
h4Bold == other.h4Bold &&
|
|
285
|
+
h5FontSize == other.h5FontSize &&
|
|
286
|
+
h5Bold == other.h5Bold &&
|
|
287
|
+
h6FontSize == other.h6FontSize &&
|
|
288
|
+
h6Bold == other.h6Bold &&
|
|
289
|
+
|
|
290
|
+
blockquoteColor == other.blockquoteColor &&
|
|
291
|
+
blockquoteBorderColor == other.blockquoteBorderColor &&
|
|
292
|
+
blockquoteStripeWidth == other.blockquoteStripeWidth &&
|
|
293
|
+
blockquoteGapWidth == other.blockquoteGapWidth &&
|
|
294
|
+
|
|
295
|
+
olGapWidth == other.olGapWidth &&
|
|
296
|
+
olMarginLeft == other.olMarginLeft &&
|
|
297
|
+
olMarkerFontWeight == other.olMarkerFontWeight &&
|
|
298
|
+
olMarkerColor == other.olMarkerColor &&
|
|
299
|
+
|
|
300
|
+
ulGapWidth == other.ulGapWidth &&
|
|
301
|
+
ulMarginLeft == other.ulMarginLeft &&
|
|
302
|
+
ulBulletSize == other.ulBulletSize &&
|
|
303
|
+
ulBulletColor == other.ulBulletColor &&
|
|
304
|
+
|
|
305
|
+
ulCheckboxBoxSize == other.ulCheckboxBoxSize &&
|
|
306
|
+
ulCheckboxGapWidth == other.ulCheckboxGapWidth &&
|
|
307
|
+
ulCheckboxMarginLeft == other.ulCheckboxMarginLeft &&
|
|
308
|
+
ulCheckboxBoxColor == other.ulCheckboxBoxColor &&
|
|
309
|
+
|
|
310
|
+
aColor == other.aColor &&
|
|
311
|
+
aUnderline == other.aUnderline &&
|
|
312
|
+
|
|
313
|
+
codeBlockColor == other.codeBlockColor &&
|
|
314
|
+
codeBlockBackgroundColor == other.codeBlockBackgroundColor &&
|
|
315
|
+
codeBlockRadius == other.codeBlockRadius &&
|
|
316
|
+
|
|
317
|
+
inlineCodeColor == other.inlineCodeColor &&
|
|
318
|
+
inlineCodeBackgroundColor == other.inlineCodeBackgroundColor &&
|
|
319
|
+
|
|
320
|
+
mentionsStyle == other.mentionsStyle
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
override fun hashCode(): Int {
|
|
324
|
+
var result = h1FontSize.hashCode()
|
|
325
|
+
result = 31 * result + h1Bold.hashCode()
|
|
326
|
+
result = 31 * result + h2FontSize.hashCode()
|
|
327
|
+
result = 31 * result + h2Bold.hashCode()
|
|
328
|
+
result = 31 * result + h3FontSize.hashCode()
|
|
329
|
+
result = 31 * result + h3Bold.hashCode()
|
|
330
|
+
result = 31 * result + h4FontSize.hashCode()
|
|
331
|
+
result = 31 * result + h4Bold.hashCode()
|
|
332
|
+
result = 31 * result + h5FontSize.hashCode()
|
|
333
|
+
result = 31 * result + h5Bold.hashCode()
|
|
334
|
+
result = 31 * result + h6FontSize.hashCode()
|
|
335
|
+
result = 31 * result + h6Bold.hashCode()
|
|
336
|
+
|
|
337
|
+
result = 31 * result + (blockquoteColor ?: 0)
|
|
338
|
+
result = 31 * result + blockquoteBorderColor.hashCode()
|
|
339
|
+
result = 31 * result + blockquoteStripeWidth.hashCode()
|
|
340
|
+
result = 31 * result + blockquoteGapWidth.hashCode()
|
|
341
|
+
|
|
342
|
+
result = 31 * result + olGapWidth.hashCode()
|
|
343
|
+
result = 31 * result + olMarginLeft.hashCode()
|
|
344
|
+
result = 31 * result + (olMarkerFontWeight?.hashCode() ?: 0)
|
|
345
|
+
result = 31 * result + (olMarkerColor ?: 0)
|
|
346
|
+
|
|
347
|
+
result = 31 * result + ulGapWidth.hashCode()
|
|
348
|
+
result = 31 * result + ulMarginLeft.hashCode()
|
|
349
|
+
result = 31 * result + ulBulletSize.hashCode()
|
|
350
|
+
result = 31 * result + ulBulletColor.hashCode()
|
|
351
|
+
|
|
352
|
+
result = 31 * result + ulCheckboxBoxSize.hashCode()
|
|
353
|
+
result = 31 * result + ulCheckboxGapWidth.hashCode()
|
|
354
|
+
result = 31 * result + ulCheckboxMarginLeft.hashCode()
|
|
355
|
+
result = 31 * result + ulCheckboxBoxColor.hashCode()
|
|
356
|
+
|
|
357
|
+
result = 31 * result + aColor.hashCode()
|
|
358
|
+
result = 31 * result + aUnderline.hashCode()
|
|
359
|
+
|
|
360
|
+
result = 31 * result + codeBlockColor.hashCode()
|
|
361
|
+
result = 31 * result + codeBlockBackgroundColor.hashCode()
|
|
362
|
+
result = 31 * result + codeBlockRadius.hashCode()
|
|
363
|
+
|
|
364
|
+
result = 31 * result + inlineCodeColor.hashCode()
|
|
365
|
+
result = 31 * result + inlineCodeBackgroundColor.hashCode()
|
|
366
|
+
|
|
367
|
+
result = 31 * result + mentionsStyle.hashCode()
|
|
368
|
+
|
|
369
|
+
return result
|
|
370
|
+
}
|
|
371
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
package com.swmansion.enriched.textinput.styles
|
|
2
|
+
|
|
3
|
+
import android.text.Editable
|
|
4
|
+
import android.text.Spannable
|
|
5
|
+
import com.swmansion.enriched.textinput.EnrichedTextInputView
|
|
6
|
+
import com.swmansion.enriched.textinput.spans.EnrichedSpans
|
|
7
|
+
import com.swmansion.enriched.textinput.utils.getSafeSpanBoundaries
|
|
8
|
+
|
|
9
|
+
class InlineStyles(
|
|
10
|
+
private val view: EnrichedTextInputView,
|
|
11
|
+
) {
|
|
12
|
+
private fun <T> setSpan(
|
|
13
|
+
spannable: Spannable,
|
|
14
|
+
type: Class<T>,
|
|
15
|
+
start: Int,
|
|
16
|
+
end: Int,
|
|
17
|
+
) {
|
|
18
|
+
val previousSpanStart = (start - 1).coerceAtLeast(0)
|
|
19
|
+
val previousSpanEnd = previousSpanStart + 1
|
|
20
|
+
val nextSpanStart = (end + 1).coerceAtMost(spannable.length)
|
|
21
|
+
val nextSpanEnd = (nextSpanStart + 1).coerceAtMost(spannable.length)
|
|
22
|
+
val previousSpans = spannable.getSpans(previousSpanStart, previousSpanEnd, type)
|
|
23
|
+
val nextSpans = spannable.getSpans(nextSpanStart, nextSpanEnd, type)
|
|
24
|
+
var minimum = start
|
|
25
|
+
var maximum = end
|
|
26
|
+
|
|
27
|
+
for (span in previousSpans) {
|
|
28
|
+
val spanStart = spannable.getSpanStart(span)
|
|
29
|
+
minimum = spanStart.coerceAtMost(minimum)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
for (span in nextSpans) {
|
|
33
|
+
val spanEnd = spannable.getSpanEnd(span)
|
|
34
|
+
maximum = spanEnd.coerceAtLeast(maximum)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
val spans = spannable.getSpans(minimum, maximum, type)
|
|
38
|
+
for (span in spans) {
|
|
39
|
+
spannable.removeSpan(span)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
val span = type.getDeclaredConstructor(HtmlStyle::class.java).newInstance(view.htmlStyle)
|
|
43
|
+
val (safeStart, safeEnd) = spannable.getSafeSpanBoundaries(minimum, maximum)
|
|
44
|
+
spannable.setSpan(span, safeStart, safeEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private fun <T> setAndMergeSpans(
|
|
48
|
+
spannable: Spannable,
|
|
49
|
+
type: Class<T>,
|
|
50
|
+
start: Int,
|
|
51
|
+
end: Int,
|
|
52
|
+
) {
|
|
53
|
+
val spans = spannable.getSpans(start, end, type)
|
|
54
|
+
|
|
55
|
+
// No spans setup for current selection, means we just need to assign new span
|
|
56
|
+
if (spans.isEmpty()) {
|
|
57
|
+
setSpan(spannable, type, start, end)
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var setSpanOnFinish = false
|
|
62
|
+
|
|
63
|
+
// Some spans are present, we have to remove spans and (optionally) apply new spans
|
|
64
|
+
for (span in spans) {
|
|
65
|
+
val spanStart = spannable.getSpanStart(span)
|
|
66
|
+
val spanEnd = spannable.getSpanEnd(span)
|
|
67
|
+
var finalStart: Int? = null
|
|
68
|
+
var finalEnd: Int? = null
|
|
69
|
+
if (spanStart == -1 || spanEnd == -1) continue
|
|
70
|
+
|
|
71
|
+
spannable.removeSpan(span)
|
|
72
|
+
|
|
73
|
+
if (start == spanStart && end == spanEnd) {
|
|
74
|
+
setSpanOnFinish = false
|
|
75
|
+
} else if (start > spanStart && end < spanEnd) {
|
|
76
|
+
setSpan(spannable, type, spanStart, start)
|
|
77
|
+
setSpan(spannable, type, end, spanEnd)
|
|
78
|
+
} else if (start == spanStart && end < spanEnd) {
|
|
79
|
+
finalStart = end
|
|
80
|
+
finalEnd = spanEnd
|
|
81
|
+
} else if (start > spanStart && end == spanEnd) {
|
|
82
|
+
finalStart = spanStart
|
|
83
|
+
finalEnd = start
|
|
84
|
+
} else if (start > spanStart) {
|
|
85
|
+
finalStart = spanStart
|
|
86
|
+
finalEnd = end
|
|
87
|
+
} else if (start < spanStart && end < spanEnd) {
|
|
88
|
+
finalStart = start
|
|
89
|
+
finalEnd = spanEnd
|
|
90
|
+
} else {
|
|
91
|
+
setSpanOnFinish = true
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!setSpanOnFinish && finalStart != null && finalEnd != null) {
|
|
95
|
+
setSpan(spannable, type, finalStart, finalEnd)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (setSpanOnFinish) {
|
|
100
|
+
setSpan(spannable, type, start, end)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
fun afterTextChanged(
|
|
105
|
+
s: Editable,
|
|
106
|
+
startCursorPosition: Int,
|
|
107
|
+
endCursorPosition: Int,
|
|
108
|
+
) {
|
|
109
|
+
if (endCursorPosition > startCursorPosition) {
|
|
110
|
+
for ((style, config) in EnrichedSpans.inlineSpans) {
|
|
111
|
+
if (view.spanState?.getStart(style) != null) continue
|
|
112
|
+
splitSpanOnInsertion(s, config.clazz, startCursorPosition, endCursorPosition)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for ((style, config) in EnrichedSpans.inlineSpans) {
|
|
117
|
+
val start = view.spanState?.getStart(style) ?: continue
|
|
118
|
+
var end = endCursorPosition
|
|
119
|
+
val spans = s.getSpans(start, end, config.clazz)
|
|
120
|
+
|
|
121
|
+
for (span in spans) {
|
|
122
|
+
end = s.getSpanEnd(span).coerceAtLeast(end)
|
|
123
|
+
s.removeSpan(span)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setSpan(s, config.clazz, start, end)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
val isBackspace = endCursorPosition == startCursorPosition
|
|
130
|
+
if (!isBackspace) {
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Collapse same-type inline spans that ended up adjacent to each other after deletion.
|
|
135
|
+
// Without this the HTML output would emit separate tags like <b>...</b><b>...</b>.
|
|
136
|
+
for ((_, config) in EnrichedSpans.inlineSpans) {
|
|
137
|
+
for (span in s.getSpans(startCursorPosition, startCursorPosition, config.clazz)) {
|
|
138
|
+
val spanStart = s.getSpanStart(span)
|
|
139
|
+
val spanEnd = s.getSpanEnd(span)
|
|
140
|
+
if (spanStart < 0 || spanEnd < 0) continue
|
|
141
|
+
setSpan(s, config.clazz, spanStart, spanEnd)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
fun applyStyleOnRange(
|
|
147
|
+
name: String,
|
|
148
|
+
start: Int,
|
|
149
|
+
end: Int,
|
|
150
|
+
) {
|
|
151
|
+
val config = EnrichedSpans.inlineSpans[name] ?: return
|
|
152
|
+
val type = config.clazz
|
|
153
|
+
val spannable = view.text as Spannable
|
|
154
|
+
val spans = spannable.getSpans(start, end, type)
|
|
155
|
+
|
|
156
|
+
if (spans.any { spannable.getSpanStart(it) <= start && spannable.getSpanEnd(it) >= end }) {
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
setAndMergeSpans(spannable, type, start, end)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
fun toggleStyle(name: String) {
|
|
164
|
+
if (view.selection == null) return
|
|
165
|
+
val (start, end) = view.selection.getInlineSelection()
|
|
166
|
+
val config = EnrichedSpans.inlineSpans[name] ?: return
|
|
167
|
+
val type = config.clazz
|
|
168
|
+
|
|
169
|
+
// We either start or end current span
|
|
170
|
+
if (start == end) {
|
|
171
|
+
val styleStart = view.spanState?.getStart(name)
|
|
172
|
+
|
|
173
|
+
if (styleStart != null) {
|
|
174
|
+
view.spanState.setStart(name, null)
|
|
175
|
+
} else {
|
|
176
|
+
view.spanState?.setStart(name, start)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
val spannable = view.text as Spannable
|
|
183
|
+
setAndMergeSpans(spannable, type, start, end)
|
|
184
|
+
view.selection.validateStyles()
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private fun <T> splitSpanOnInsertion(
|
|
188
|
+
spannable: Spannable,
|
|
189
|
+
type: Class<T>,
|
|
190
|
+
insertStart: Int,
|
|
191
|
+
insertEnd: Int,
|
|
192
|
+
) {
|
|
193
|
+
val spans = spannable.getSpans(insertStart, insertEnd, type)
|
|
194
|
+
for (span in spans) {
|
|
195
|
+
val spanStart = spannable.getSpanStart(span)
|
|
196
|
+
val spanEnd = spannable.getSpanEnd(span)
|
|
197
|
+
if (spanStart < 0 || spanEnd < 0) continue
|
|
198
|
+
|
|
199
|
+
spannable.removeSpan(span)
|
|
200
|
+
|
|
201
|
+
if (spanStart < insertStart) {
|
|
202
|
+
val (safeStart, safeEnd) = spannable.getSafeSpanBoundaries(spanStart, insertStart)
|
|
203
|
+
val left = type.getDeclaredConstructor(HtmlStyle::class.java).newInstance(view.htmlStyle)
|
|
204
|
+
spannable.setSpan(left, safeStart, safeEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
205
|
+
}
|
|
206
|
+
if (spanEnd > insertEnd) {
|
|
207
|
+
val (safeStart, safeEnd) = spannable.getSafeSpanBoundaries(insertEnd, spanEnd)
|
|
208
|
+
val right = type.getDeclaredConstructor(HtmlStyle::class.java).newInstance(view.htmlStyle)
|
|
209
|
+
spannable.setSpan(right, safeStart, safeEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
fun removeStyle(
|
|
215
|
+
name: String,
|
|
216
|
+
start: Int,
|
|
217
|
+
end: Int,
|
|
218
|
+
): Boolean {
|
|
219
|
+
val config = EnrichedSpans.inlineSpans[name] ?: return false
|
|
220
|
+
val spannable = view.text as Spannable
|
|
221
|
+
val spans = spannable.getSpans(start, end, config.clazz)
|
|
222
|
+
if (spans.isEmpty()) return false
|
|
223
|
+
|
|
224
|
+
for (span in spans) {
|
|
225
|
+
spannable.removeSpan(span)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return true
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
fun getStyleRange(): Pair<Int, Int> = view.selection?.getInlineSelection() ?: Pair(0, 0)
|
|
232
|
+
}
|