react-native-enriched-html 0.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +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/EnrichedSpanFlags.kt +39 -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 +1057 -0
- package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt +83 -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 +84 -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 +362 -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 +86 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt +1144 -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 +65 -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 +40 -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 +366 -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 +244 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ListStyles.kt +261 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt +440 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt +435 -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 +342 -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 +157 -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 +107 -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 +973 -0
- package/cpp/parser/GumboParser.cpp +16 -0
- package/cpp/parser/GumboParser.hpp +23 -0
- package/cpp/tests/GumboParserTest.cpp +511 -0
- package/ios/EnrichedTextInputView.h +54 -0
- package/ios/EnrichedTextInputView.mm +2182 -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 +465 -0
- package/ios/extensions/StringExtension.h +15 -0
- package/ios/extensions/StringExtension.mm +144 -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 +14 -0
- package/ios/htmlParser/HtmlParser.mm +1486 -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 +228 -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 +114 -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 +518 -0
- package/ios/styles/MentionStyle.mm +592 -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 +182 -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 +296 -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 +5 -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 +14 -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/EnrichedText.css +343 -0
- package/lib/module/web/EnrichedText.js +55 -0
- package/lib/module/web/EnrichedText.js.map +1 -0
- package/lib/module/web/EnrichedTextInput.js +316 -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/constants/brokenImageGlyph.js +9 -0
- package/lib/module/web/constants/brokenImageGlyph.js.map +1 -0
- package/lib/module/web/constants/classNames.js +5 -0
- package/lib/module/web/constants/classNames.js.map +1 -0
- package/lib/module/web/emitLinkDetected.js +12 -0
- package/lib/module/web/emitLinkDetected.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 +180 -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/EnrichedTextAlign.js +82 -0
- package/lib/module/web/formats/EnrichedTextAlign.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 +64 -0
- package/lib/module/web/formats/applyWrappingListToSelection.js.map +1 -0
- package/lib/module/web/formats/formatRules.js +84 -0
- package/lib/module/web/formats/formatRules.js.map +1 -0
- package/lib/module/web/formats/listKeyboard.js +53 -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/normalization/checkboxHtmlNormalizer.js +54 -0
- package/lib/module/web/normalization/checkboxHtmlNormalizer.js.map +1 -0
- package/lib/module/web/normalization/htmlNormalizer.js +514 -0
- package/lib/module/web/normalization/htmlNormalizer.js.map +1 -0
- package/lib/module/web/normalization/prepareHtmlForWeb.js +78 -0
- package/lib/module/web/normalization/prepareHtmlForWeb.js.map +1 -0
- package/lib/module/web/normalization/tiptapHtmlNormalizer.js +34 -0
- package/lib/module/web/normalization/tiptapHtmlNormalizer.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/AutolinkPlugin/autolinkRegex.js +27 -0
- package/lib/module/web/pmPlugins/AutolinkPlugin/autolinkRegex.js.map +1 -0
- package/lib/module/web/pmPlugins/AutolinkPlugin/index.js +178 -0
- package/lib/module/web/pmPlugins/AutolinkPlugin/index.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 +86 -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 +57 -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/types.js +4 -0
- package/lib/module/web/pmPlugins/MentionPlugin/types.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/useMentionEvents.js +105 -0
- package/lib/module/web/pmPlugins/MentionPlugin/useMentionEvents.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 +134 -0
- package/lib/module/web/pmPlugins/ShortcutPlugin.js.map +1 -0
- package/lib/module/web/pmPlugins/StrictMarksPlugin.js +100 -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/sanitization/htmlSanitizer.js +10 -0
- package/lib/module/web/sanitization/htmlSanitizer.js.map +1 -0
- package/lib/module/web/styleConversion/buildMentionRulesCSS.js +39 -0
- package/lib/module/web/styleConversion/buildMentionRulesCSS.js.map +1 -0
- package/lib/module/web/styleConversion/enrichedBaseStyleToCSSProperties.js +159 -0
- package/lib/module/web/styleConversion/enrichedBaseStyleToCSSProperties.js.map +1 -0
- package/lib/module/web/styleConversion/enrichedInputStyleToCSSProperties.js +7 -0
- package/lib/module/web/styleConversion/enrichedInputStyleToCSSProperties.js.map +1 -0
- package/lib/module/web/styleConversion/enrichedTextStyleToCSSProperties.js +44 -0
- package/lib/module/web/styleConversion/enrichedTextStyleToCSSProperties.js.map +1 -0
- package/lib/module/web/styleConversion/enrichedThemingToCSSProperties.js +18 -0
- package/lib/module/web/styleConversion/enrichedThemingToCSSProperties.js.map +1 -0
- package/lib/module/web/styleConversion/htmlStyleToCSSVariables.js +168 -0
- package/lib/module/web/styleConversion/htmlStyleToCSSVariables.js.map +1 -0
- package/lib/module/web/styleConversion/inlineImageCSSVariables.js +7 -0
- package/lib/module/web/styleConversion/inlineImageCSSVariables.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/useImageErrorFallback.js +33 -0
- package/lib/module/web/useImageErrorFallback.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 +91 -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 +55 -0
- package/lib/module/web/useOnLinkDetected.js.map +1 -0
- package/lib/module/web/usePressInteractions.js +19 -0
- package/lib/module/web/usePressInteractions.js.map +1 -0
- package/lib/module/web/useStableRef.js +13 -0
- package/lib/module/web/useStableRef.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/index.d.ts +4 -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/EnrichedText.d.ts +4 -0
- package/lib/typescript/src/web/EnrichedText.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/constants/brokenImageGlyph.d.ts +3 -0
- package/lib/typescript/src/web/constants/brokenImageGlyph.d.ts.map +1 -0
- package/lib/typescript/src/web/constants/classNames.d.ts +3 -0
- package/lib/typescript/src/web/constants/classNames.d.ts.map +1 -0
- package/lib/typescript/src/web/emitLinkDetected.d.ts +10 -0
- package/lib/typescript/src/web/emitLinkDetected.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 +8 -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/EnrichedTextAlign.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedTextAlign.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 +12 -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/normalization/checkboxHtmlNormalizer.d.ts +3 -0
- package/lib/typescript/src/web/normalization/checkboxHtmlNormalizer.d.ts.map +1 -0
- package/lib/typescript/src/web/normalization/htmlNormalizer.d.ts +2 -0
- package/lib/typescript/src/web/normalization/htmlNormalizer.d.ts.map +1 -0
- package/lib/typescript/src/web/normalization/prepareHtmlForWeb.d.ts +2 -0
- package/lib/typescript/src/web/normalization/prepareHtmlForWeb.d.ts.map +1 -0
- package/lib/typescript/src/web/normalization/tiptapHtmlNormalizer.d.ts +3 -0
- package/lib/typescript/src/web/normalization/tiptapHtmlNormalizer.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/AutolinkPlugin/autolinkRegex.d.ts +7 -0
- package/lib/typescript/src/web/pmPlugins/AutolinkPlugin/autolinkRegex.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/AutolinkPlugin/index.d.ts +8 -0
- package/lib/typescript/src/web/pmPlugins/AutolinkPlugin/index.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/types.d.ts +20 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/types.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/useMentionEvents.d.ts +4 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/useMentionEvents.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 +15 -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/sanitization/htmlSanitizer.d.ts +2 -0
- package/lib/typescript/src/web/sanitization/htmlSanitizer.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/enrichedBaseStyleToCSSProperties.d.ts +8 -0
- package/lib/typescript/src/web/styleConversion/enrichedBaseStyleToCSSProperties.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/enrichedInputStyleToCSSProperties.d.ts +5 -0
- package/lib/typescript/src/web/styleConversion/enrichedInputStyleToCSSProperties.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/enrichedTextStyleToCSSProperties.d.ts +4 -0
- package/lib/typescript/src/web/styleConversion/enrichedTextStyleToCSSProperties.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/enrichedThemingToCSSProperties.d.ts +9 -0
- package/lib/typescript/src/web/styleConversion/enrichedThemingToCSSProperties.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/htmlStyleToCSSVariables.d.ts +11 -0
- package/lib/typescript/src/web/styleConversion/htmlStyleToCSSVariables.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/inlineImageCSSVariables.d.ts +3 -0
- package/lib/typescript/src/web/styleConversion/inlineImageCSSVariables.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/useImageErrorFallback.d.ts +3 -0
- package/lib/typescript/src/web/useImageErrorFallback.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/lib/typescript/src/web/usePressInteractions.d.ts +2 -0
- package/lib/typescript/src/web/usePressInteractions.d.ts.map +1 -0
- package/lib/typescript/src/web/useStableRef.d.ts +3 -0
- package/lib/typescript/src/web/useStableRef.d.ts.map +1 -0
- package/package.json +258 -1
- package/react-native.config.js +16 -0
- package/src/index.native.tsx +34 -0
- package/src/index.tsx +25 -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 +866 -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 +182 -0
- package/src/utils/nullthrows.ts +7 -0
- package/src/utils/regexParser.ts +56 -0
- package/src/web/EnrichedText.css +343 -0
- package/src/web/EnrichedText.tsx +82 -0
- package/src/web/EnrichedTextInput.tsx +417 -0
- package/src/web/adaptWebToNativeEvent.ts +37 -0
- package/src/web/constants/brokenImageGlyph.ts +7 -0
- package/src/web/constants/classNames.ts +2 -0
- package/src/web/emitLinkDetected.ts +29 -0
- package/src/web/formats/EnrichedBlockquote.ts +37 -0
- package/src/web/formats/EnrichedBold.ts +16 -0
- package/src/web/formats/EnrichedCheckboxItem.ts +35 -0
- package/src/web/formats/EnrichedCheckboxList.ts +50 -0
- package/src/web/formats/EnrichedCode.ts +13 -0
- package/src/web/formats/EnrichedCodeBlock.ts +54 -0
- package/src/web/formats/EnrichedHeading.ts +37 -0
- package/src/web/formats/EnrichedImage.ts +59 -0
- package/src/web/formats/EnrichedImageNodeView.tsx +87 -0
- package/src/web/formats/EnrichedItalic.ts +16 -0
- package/src/web/formats/EnrichedLink.ts +204 -0
- package/src/web/formats/EnrichedListItem.ts +17 -0
- package/src/web/formats/EnrichedMention.ts +55 -0
- package/src/web/formats/EnrichedOrderedList.ts +43 -0
- package/src/web/formats/EnrichedStrike.ts +16 -0
- package/src/web/formats/EnrichedTextAlign.ts +88 -0
- package/src/web/formats/EnrichedUnderline.ts +16 -0
- package/src/web/formats/EnrichedUnorderedList.ts +53 -0
- package/src/web/formats/applyWrappingListToSelection.ts +76 -0
- package/src/web/formats/formatRules.ts +128 -0
- package/src/web/formats/listKeyboard.ts +63 -0
- package/src/web/formats/wrappedBlockKeyboard.ts +76 -0
- package/src/web/normalization/checkboxHtmlNormalizer.ts +62 -0
- package/src/web/normalization/htmlNormalizer.ts +656 -0
- package/src/web/normalization/prepareHtmlForWeb.ts +93 -0
- package/src/web/normalization/tiptapHtmlNormalizer.ts +43 -0
- package/src/web/pasteImages.ts +96 -0
- package/src/web/pastedImageDimensions.ts +40 -0
- package/src/web/pmPlugins/AutolinkPlugin/autolinkRegex.ts +43 -0
- package/src/web/pmPlugins/AutolinkPlugin/index.ts +274 -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 +102 -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 +73 -0
- package/src/web/pmPlugins/MentionPlugin/startMention.ts +14 -0
- package/src/web/pmPlugins/MentionPlugin/stripPartialMentionMarks.ts +20 -0
- package/src/web/pmPlugins/MentionPlugin/types.ts +22 -0
- package/src/web/pmPlugins/MentionPlugin/useMentionEvents.ts +114 -0
- package/src/web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.ts +57 -0
- package/src/web/pmPlugins/ShortcutPlugin.ts +105 -0
- package/src/web/pmPlugins/StrictMarksPlugin.ts +134 -0
- package/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.ts +84 -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/sanitization/htmlSanitizer.ts +8 -0
- package/src/web/styleConversion/buildMentionRulesCSS.ts +61 -0
- package/src/web/styleConversion/enrichedBaseStyleToCSSProperties.ts +228 -0
- package/src/web/styleConversion/enrichedInputStyleToCSSProperties.ts +13 -0
- package/src/web/styleConversion/enrichedTextStyleToCSSProperties.ts +53 -0
- package/src/web/styleConversion/enrichedThemingToCSSProperties.ts +34 -0
- package/src/web/styleConversion/htmlStyleToCSSVariables.ts +277 -0
- package/src/web/styleConversion/inlineImageCSSVariables.ts +6 -0
- package/src/web/styleConversion/mentionIndicatorCssKey.ts +14 -0
- package/src/web/styleConversion/toColor.ts +17 -0
- package/src/web/useImageErrorFallback.ts +37 -0
- package/src/web/useOnChangeHtml.ts +14 -0
- package/src/web/useOnChangeState.ts +127 -0
- package/src/web/useOnChangeText.ts +15 -0
- package/src/web/useOnEditorChange.ts +33 -0
- package/src/web/useOnLinkDetected.ts +70 -0
- package/src/web/usePressInteractions.tsx +22 -0
- package/src/web/useStableRef.ts +12 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { Mark, type ResolvedPos, type Schema } from '@tiptap/pm/model';
|
|
3
|
+
import { Plugin, PluginKey, type EditorState } from '@tiptap/pm/state';
|
|
4
|
+
|
|
5
|
+
const NONINCLUSIVE_MARKS = ['link', 'mention'] as const;
|
|
6
|
+
|
|
7
|
+
function stripNonInclusiveMarksFromSet(
|
|
8
|
+
schema: Schema,
|
|
9
|
+
marks: readonly Mark[]
|
|
10
|
+
): readonly Mark[] {
|
|
11
|
+
let out = marks.slice();
|
|
12
|
+
for (const name of NONINCLUSIVE_MARKS) {
|
|
13
|
+
const markType = schema.marks[name];
|
|
14
|
+
if (!markType?.isInSet(out)) continue;
|
|
15
|
+
out = out.filter((m) => m.type !== markType);
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function stripNonInclusiveMarksIfAfterIsOut(
|
|
21
|
+
schema: Schema,
|
|
22
|
+
$from: ResolvedPos
|
|
23
|
+
): readonly Mark[] {
|
|
24
|
+
const nodeBefore = $from.nodeBefore;
|
|
25
|
+
if (!nodeBefore) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
let out = nodeBefore.marks;
|
|
29
|
+
for (const name of NONINCLUSIVE_MARKS) {
|
|
30
|
+
const markType = schema.marks[name];
|
|
31
|
+
if (!markType?.isInSet(out)) continue;
|
|
32
|
+
const afterHasMark =
|
|
33
|
+
$from.nodeAfter != null && markType.isInSet($from.nodeAfter.marks);
|
|
34
|
+
if (!afterHasMark) {
|
|
35
|
+
out = out.filter((m) => m.type !== markType);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function resolveStrictMarks(
|
|
42
|
+
$from: ResolvedPos,
|
|
43
|
+
oldState: EditorState,
|
|
44
|
+
newState: EditorState,
|
|
45
|
+
docChanged: boolean,
|
|
46
|
+
textLengthChanged: boolean
|
|
47
|
+
): readonly Mark[] {
|
|
48
|
+
// Editor completely empty
|
|
49
|
+
if (newState.doc.textContent.length === 0) {
|
|
50
|
+
return textLengthChanged
|
|
51
|
+
? []
|
|
52
|
+
: (oldState.storedMarks ?? newState.storedMarks ?? []);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Character to the left: strictly inherit from it
|
|
56
|
+
if ($from.nodeBefore) {
|
|
57
|
+
// Non-inclusive marks: do not carry onto text typed after the last marked
|
|
58
|
+
// character (e.g. space exits link/mention, matching native).
|
|
59
|
+
return stripNonInclusiveMarksIfAfterIsOut(newState.schema, $from);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Start of line with text to the right
|
|
63
|
+
if ($from.nodeAfter) {
|
|
64
|
+
if (!docChanged) {
|
|
65
|
+
return []; // Pure cursor movement: kill RTL mark bleeding
|
|
66
|
+
}
|
|
67
|
+
const old$ = oldState.selection.$from;
|
|
68
|
+
const { nodeBefore: oldBefore, nodeAfter: oldAfter } = old$;
|
|
69
|
+
// Styled|plain boundary after Enter/paste/etc.: inherit the left inline's marks so
|
|
70
|
+
// bold, code, and other marks behave the same on a new paragraph.
|
|
71
|
+
if (
|
|
72
|
+
oldBefore &&
|
|
73
|
+
oldAfter &&
|
|
74
|
+
!Mark.sameSet(oldBefore.marks, oldAfter.marks)
|
|
75
|
+
) {
|
|
76
|
+
return stripNonInclusiveMarksFromSet(newState.schema, oldBefore.marks);
|
|
77
|
+
}
|
|
78
|
+
return stripNonInclusiveMarksFromSet(
|
|
79
|
+
newState.schema,
|
|
80
|
+
$from.nodeAfter.marks
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Completely empty line
|
|
85
|
+
if (textLengthChanged) {
|
|
86
|
+
const prevEndPos = $from.before() - 1;
|
|
87
|
+
return prevEndPos > 0 ? newState.doc.resolve(prevEndPos).marks() : [];
|
|
88
|
+
}
|
|
89
|
+
if (oldState.storedMarks) {
|
|
90
|
+
return oldState.storedMarks; // Structural nav (Enter/Backspace): keep explicit marks
|
|
91
|
+
}
|
|
92
|
+
return newState.storedMarks ?? $from.marks();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const StrictMarksPlugin = Extension.create({
|
|
96
|
+
name: 'strictMarksPlugin',
|
|
97
|
+
addProseMirrorPlugins() {
|
|
98
|
+
return [
|
|
99
|
+
new Plugin({
|
|
100
|
+
key: new PluginKey('strictMarks'),
|
|
101
|
+
appendTransaction(transactions, oldState, newState) {
|
|
102
|
+
const { selection } = newState;
|
|
103
|
+
|
|
104
|
+
if (!selection.empty) return null;
|
|
105
|
+
|
|
106
|
+
const docChanged = !oldState.doc.eq(newState.doc);
|
|
107
|
+
const selChanged = !oldState.selection.eq(newState.selection);
|
|
108
|
+
if (!docChanged && !selChanged) return null;
|
|
109
|
+
|
|
110
|
+
const isExplicitToggle =
|
|
111
|
+
!docChanged && transactions.some((tr) => tr.storedMarks !== null);
|
|
112
|
+
if (isExplicitToggle) return null;
|
|
113
|
+
|
|
114
|
+
const { $from } = selection;
|
|
115
|
+
const textLengthChanged =
|
|
116
|
+
oldState.doc.textContent.length !== newState.doc.textContent.length;
|
|
117
|
+
|
|
118
|
+
const strictMarks = resolveStrictMarks(
|
|
119
|
+
$from,
|
|
120
|
+
oldState,
|
|
121
|
+
newState,
|
|
122
|
+
docChanged,
|
|
123
|
+
textLengthChanged
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const activeMarks = newState.storedMarks ?? $from.marks();
|
|
127
|
+
if (Mark.sameSet(strictMarks, activeMarks)) return null;
|
|
128
|
+
|
|
129
|
+
return newState.tr.setStoredMarks(strictMarks);
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
132
|
+
];
|
|
133
|
+
},
|
|
134
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Extension, type CommandProps } from '@tiptap/core';
|
|
2
|
+
import {
|
|
3
|
+
Plugin,
|
|
4
|
+
PluginKey,
|
|
5
|
+
type EditorState,
|
|
6
|
+
type Transaction,
|
|
7
|
+
} from '@tiptap/pm/state';
|
|
8
|
+
import type { HtmlStyle } from '../../types';
|
|
9
|
+
import { HEADING_TAGS } from '../formats/EnrichedHeading';
|
|
10
|
+
|
|
11
|
+
declare module '@tiptap/core' {
|
|
12
|
+
interface Commands<ReturnType> {
|
|
13
|
+
stripBoldInStyledHeadings: {
|
|
14
|
+
// Remove redundant bold marks from headings whose level is already bold via `htmlStyle` CSS.
|
|
15
|
+
normalizeBoldInStyledHeadings: () => ReturnType;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface StripBoldInStyledHeadingsPluginOptions {
|
|
21
|
+
getHtmlStyle: () => Required<HtmlStyle>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function transactionStripBoldInCssBoldHeadings(
|
|
25
|
+
state: EditorState,
|
|
26
|
+
htmlStyle: Required<HtmlStyle>
|
|
27
|
+
): Transaction | null {
|
|
28
|
+
const boldType = state.schema.marks.bold;
|
|
29
|
+
if (!boldType) return null;
|
|
30
|
+
|
|
31
|
+
const tr = state.tr;
|
|
32
|
+
state.doc.descendants((node, pos) => {
|
|
33
|
+
if (node.type.name !== 'heading') return true;
|
|
34
|
+
const level = node.attrs.level as number;
|
|
35
|
+
if (level < 1 || level > HEADING_TAGS.length) return false;
|
|
36
|
+
const key = HEADING_TAGS[level - 1]!;
|
|
37
|
+
if (htmlStyle[key].bold) {
|
|
38
|
+
tr.removeMark(pos + 1, pos + node.nodeSize - 1, boldType);
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return tr.steps.length > 0 ? tr : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const StripBoldInStyledHeadingsPlugin =
|
|
47
|
+
Extension.create<StripBoldInStyledHeadingsPluginOptions>({
|
|
48
|
+
name: 'stripBoldInStyledHeadings',
|
|
49
|
+
addOptions() {
|
|
50
|
+
return {
|
|
51
|
+
getHtmlStyle: () => {
|
|
52
|
+
throw new Error(
|
|
53
|
+
'StripBoldInStyledHeadingsPlugin.configure({ getHtmlStyle }) is required'
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
addCommands() {
|
|
59
|
+
return {
|
|
60
|
+
normalizeBoldInStyledHeadings:
|
|
61
|
+
() =>
|
|
62
|
+
({ state, dispatch }: CommandProps) => {
|
|
63
|
+
const htmlStyle = this.options.getHtmlStyle();
|
|
64
|
+
const tr = transactionStripBoldInCssBoldHeadings(state, htmlStyle);
|
|
65
|
+
if (!tr) return false;
|
|
66
|
+
if (dispatch) dispatch(tr);
|
|
67
|
+
return true;
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
addProseMirrorPlugins() {
|
|
72
|
+
return [
|
|
73
|
+
new Plugin({
|
|
74
|
+
key: new PluginKey('stripBoldInStyledHeadings'),
|
|
75
|
+
appendTransaction: (transactions, _oldState, newState) => {
|
|
76
|
+
if (!transactions.some((tr) => tr.docChanged)) return;
|
|
77
|
+
const htmlStyle = this.options.getHtmlStyle();
|
|
78
|
+
|
|
79
|
+
return transactionStripBoldInCssBoldHeadings(newState, htmlStyle);
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
];
|
|
83
|
+
},
|
|
84
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
3
|
+
|
|
4
|
+
export const StripMarksInCodeBlockPlugin = Extension.create({
|
|
5
|
+
name: 'stripMarksInCodeBlock',
|
|
6
|
+
|
|
7
|
+
addProseMirrorPlugins() {
|
|
8
|
+
return [
|
|
9
|
+
new Plugin({
|
|
10
|
+
key: new PluginKey('stripMarksInCodeBlock'),
|
|
11
|
+
appendTransaction: (transactions, _oldState, newState) => {
|
|
12
|
+
if (!transactions.some((tr) => tr.docChanged)) return;
|
|
13
|
+
|
|
14
|
+
const tr = newState.tr;
|
|
15
|
+
|
|
16
|
+
const allMarks = Object.values(newState.schema.marks);
|
|
17
|
+
|
|
18
|
+
newState.doc.descendants((node, pos) => {
|
|
19
|
+
if (node.type.name === 'codeBlock') {
|
|
20
|
+
allMarks.forEach((markType) => {
|
|
21
|
+
tr.removeMark(pos + 1, pos + node.nodeSize - 1, markType);
|
|
22
|
+
});
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return true;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return tr.steps.length > 0 ? tr : null;
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
];
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
3
|
+
|
|
4
|
+
export const StripMarksOnImagePlugin = Extension.create({
|
|
5
|
+
name: 'stripMarksOnImage',
|
|
6
|
+
|
|
7
|
+
addProseMirrorPlugins() {
|
|
8
|
+
return [
|
|
9
|
+
new Plugin({
|
|
10
|
+
key: new PluginKey('stripMarksOnImage'),
|
|
11
|
+
appendTransaction: (transactions, _oldState, newState) => {
|
|
12
|
+
if (!transactions.some((tr) => tr.docChanged)) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const tr = newState.tr;
|
|
17
|
+
let modified = false;
|
|
18
|
+
|
|
19
|
+
newState.doc.descendants((node, pos) => {
|
|
20
|
+
if (node.type.name === 'image' && node.marks.length > 0) {
|
|
21
|
+
node.marks.forEach((mark) => {
|
|
22
|
+
tr.removeMark(pos, pos + node.nodeSize, mark);
|
|
23
|
+
});
|
|
24
|
+
modified = true;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return modified ? tr : null;
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
];
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Node } from '@tiptap/pm/model';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Position model mismatch: ProseMirror vs native (iOS/Android)
|
|
5
|
+
*
|
|
6
|
+
* Native selection/cursor offsets are plain string indices in rendered text
|
|
7
|
+
* Block boundaries are represented by a single '\n'.
|
|
8
|
+
*
|
|
9
|
+
* ProseMirror positions are tree positions. Entering/leaving block nodes
|
|
10
|
+
* consumes extra positions that do not map to extra native characters.
|
|
11
|
+
* Crossing one paragraph boundary is 1 native char ('\n') but usually 2 PM
|
|
12
|
+
* positions (close paragraph + open next paragraph).
|
|
13
|
+
*
|
|
14
|
+
* Example for three paragraphs "AAAA", "BBBB", "CCCC":
|
|
15
|
+
*
|
|
16
|
+
* PM: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
|
17
|
+
* Native: 0 1 2 3 4 4 5 6 7 8 9 9 10 11 12 13 14
|
|
18
|
+
*
|
|
19
|
+
* PM 5 and PM 6 both map to native 4, PM 11 and PM 12 both map to native 9.
|
|
20
|
+
*
|
|
21
|
+
* Inline images occupy one index in the native plain string as a '\ufffc' character,
|
|
22
|
+
* we do the same for the web implementation.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Plain text in the native coordinate model for [from, to), including '\ufffc' per inline image.
|
|
27
|
+
*/
|
|
28
|
+
export function nativeLeafText(doc: Node, from: number, to: number): string {
|
|
29
|
+
return doc.textBetween(from, to, '\n', () => '\ufffc');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function nativeTextLength(doc: Node, from: number, to: number): number {
|
|
33
|
+
return nativeLeafText(doc, from, to).length;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns the native position for a given TipTap document position.
|
|
38
|
+
*/
|
|
39
|
+
export function tiptapPosToNativePos(doc: Node, tiptapPos: number): number {
|
|
40
|
+
if (tiptapPos <= 1) return 0;
|
|
41
|
+
return nativeTextLength(doc, 0, tiptapPos);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Returns the TipTap document position for a given native position.
|
|
46
|
+
*
|
|
47
|
+
* Traverses only text-bearing block nodes (paragraphs, headings, etc.),
|
|
48
|
+
* skipping wrapper nodes like block quotes and lists. This ensures the result
|
|
49
|
+
* is always a valid cursor position drilled down to the innermost content node.
|
|
50
|
+
*/
|
|
51
|
+
export function nativePosToTiptapPos(doc: Node, nativePos: number): number {
|
|
52
|
+
let currentNativePos = 0;
|
|
53
|
+
let targetTiptapPos = -1;
|
|
54
|
+
let lastValidTiptapPos = -1;
|
|
55
|
+
|
|
56
|
+
doc.descendants((node, pos) => {
|
|
57
|
+
if (targetTiptapPos !== -1) return false;
|
|
58
|
+
|
|
59
|
+
// Only consider text-bearing leaf blocks (paragraphs, headings, code blocks).
|
|
60
|
+
// Wrapper nodes (lists, list items, block quotes) are skipped
|
|
61
|
+
if (node.isTextblock) {
|
|
62
|
+
const textLen = node.textContent.length;
|
|
63
|
+
|
|
64
|
+
if (currentNativePos + textLen >= nativePos) {
|
|
65
|
+
// pos is before the opening tag; pos+1 is the first position inside.
|
|
66
|
+
const offset = Math.max(0, nativePos - currentNativePos);
|
|
67
|
+
targetTiptapPos = pos + 1 + offset;
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
currentNativePos += textLen + 1; // +1 for the '\n' block separator
|
|
72
|
+
lastValidTiptapPos = pos + 1 + textLen;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return true;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (targetTiptapPos !== -1) return targetTiptapPos;
|
|
79
|
+
if (lastValidTiptapPos !== -1) return lastValidTiptapPos;
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReturnKeyTypeOptions } from 'react-native';
|
|
2
|
+
|
|
3
|
+
// Keywords for the HTML global [`enterkeyhint`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/enterkeyhint) attribute
|
|
4
|
+
export type EnterKeyHint =
|
|
5
|
+
| 'enter'
|
|
6
|
+
| 'done'
|
|
7
|
+
| 'go'
|
|
8
|
+
| 'next'
|
|
9
|
+
| 'previous'
|
|
10
|
+
| 'search'
|
|
11
|
+
| 'send';
|
|
12
|
+
|
|
13
|
+
// Maps React Native `returnKeyType` to the HTML global `enterkeyhint` attribute
|
|
14
|
+
// if possible, otherwise falls back to enter.
|
|
15
|
+
export function returnKeyTypeToEnterKeyHint(
|
|
16
|
+
returnKeyType: ReturnKeyTypeOptions | undefined
|
|
17
|
+
): EnterKeyHint {
|
|
18
|
+
switch (returnKeyType) {
|
|
19
|
+
case 'done':
|
|
20
|
+
case 'go':
|
|
21
|
+
case 'next':
|
|
22
|
+
case 'previous':
|
|
23
|
+
case 'search':
|
|
24
|
+
case 'send':
|
|
25
|
+
return returnKeyType;
|
|
26
|
+
default:
|
|
27
|
+
return 'enter';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EnrichedTextHtmlStyle,
|
|
3
|
+
HtmlStyle,
|
|
4
|
+
MentionStyleProperties,
|
|
5
|
+
} from '../../types';
|
|
6
|
+
import { isMentionStyleRecord } from '../../utils/isMentionStyleRecord';
|
|
7
|
+
import {
|
|
8
|
+
ENRICHED_TEXT_CLASSNAME,
|
|
9
|
+
ENRICHED_TEXT_INPUT_CLASSNAME,
|
|
10
|
+
} from '../constants/classNames';
|
|
11
|
+
import { ET_MENTION_CSS_VARS } from './htmlStyleToCSSVariables';
|
|
12
|
+
import { MENTION_STYLE_DEFAULT_KEY } from './mentionIndicatorCssKey';
|
|
13
|
+
|
|
14
|
+
function escapeIndicatorForCssAttributeSelector(indicator: string): string {
|
|
15
|
+
if (typeof CSS !== 'undefined' && typeof CSS.escape === 'function') {
|
|
16
|
+
return CSS.escape(indicator);
|
|
17
|
+
}
|
|
18
|
+
return indicator.replace(/["\\]/g, '\\$&');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function mentionSelector(className: string, indicator: string): string {
|
|
22
|
+
return indicator === MENTION_STYLE_DEFAULT_KEY
|
|
23
|
+
? `.${className} mention`
|
|
24
|
+
: `.${className} mention[indicator="${escapeIndicatorForCssAttributeSelector(indicator)}"]`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function buildMentionRulesCSS(
|
|
28
|
+
htmlStyle?: HtmlStyle | EnrichedTextHtmlStyle
|
|
29
|
+
): string {
|
|
30
|
+
const mapRaw = htmlStyle?.mention;
|
|
31
|
+
if (!mapRaw || typeof mapRaw !== 'object' || !isMentionStyleRecord(mapRaw)) {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const map: Record<string, MentionStyleProperties> = mapRaw;
|
|
36
|
+
const keys = Object.keys(map);
|
|
37
|
+
if (keys.length === 0) {
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const lines: string[] = [];
|
|
42
|
+
|
|
43
|
+
for (const indicator of keys) {
|
|
44
|
+
const inputSelector = mentionSelector(
|
|
45
|
+
ENRICHED_TEXT_INPUT_CLASSNAME,
|
|
46
|
+
indicator
|
|
47
|
+
);
|
|
48
|
+
const textSelector = mentionSelector(ENRICHED_TEXT_CLASSNAME, indicator);
|
|
49
|
+
|
|
50
|
+
lines.push(
|
|
51
|
+
`${inputSelector},
|
|
52
|
+
${textSelector} {
|
|
53
|
+
color: var(${ET_MENTION_CSS_VARS.color(indicator)});
|
|
54
|
+
background-color: var(${ET_MENTION_CSS_VARS.backgroundColor(indicator)});
|
|
55
|
+
text-decoration-line: var(${ET_MENTION_CSS_VARS.textDecorationLine(indicator)});
|
|
56
|
+
}`.trim()
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return lines.join('\n');
|
|
61
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { EnrichedInputStyle } from '../../types';
|
|
3
|
+
import type {
|
|
4
|
+
AnimatableNumericValue,
|
|
5
|
+
DimensionValue,
|
|
6
|
+
TextStyle,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import { toColor } from './toColor';
|
|
9
|
+
|
|
10
|
+
export interface StyleConversionExtraOptions {
|
|
11
|
+
scrollEnabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function enrichedBaseStyleToCSSProperties(
|
|
15
|
+
style: EnrichedInputStyle | TextStyle,
|
|
16
|
+
extraOptions: StyleConversionExtraOptions = {}
|
|
17
|
+
): CSSProperties {
|
|
18
|
+
const css: CSSProperties = {
|
|
19
|
+
// Dimensions
|
|
20
|
+
width: toPx(style.width),
|
|
21
|
+
height: toPx(style.height),
|
|
22
|
+
minWidth: toPx(style.minWidth),
|
|
23
|
+
maxWidth: toPx(style.maxWidth),
|
|
24
|
+
minHeight: toPx(style.minHeight),
|
|
25
|
+
maxHeight: toPx(style.maxHeight),
|
|
26
|
+
top: toPx(style.top),
|
|
27
|
+
bottom: toPx(style.bottom),
|
|
28
|
+
left: toPx(style.left),
|
|
29
|
+
right: toPx(style.right),
|
|
30
|
+
inset: toPx(style.inset),
|
|
31
|
+
insetBlock: toPx(style.insetBlock),
|
|
32
|
+
insetBlockEnd: toPx(style.insetBlockEnd),
|
|
33
|
+
insetBlockStart: toPx(style.insetBlockStart),
|
|
34
|
+
insetInline: toPx(style.insetInline),
|
|
35
|
+
insetInlineEnd: toPx(style.insetInlineEnd ?? style.end),
|
|
36
|
+
insetInlineStart: toPx(style.insetInlineStart ?? style.start),
|
|
37
|
+
|
|
38
|
+
// Margin - specific properties take precedence over shorthands (RN behavior)
|
|
39
|
+
margin: toPx(style.margin),
|
|
40
|
+
marginTop: toPx(style.marginTop ?? style.marginVertical),
|
|
41
|
+
marginBottom: toPx(style.marginBottom ?? style.marginVertical),
|
|
42
|
+
marginLeft: toPx(style.marginLeft ?? style.marginHorizontal),
|
|
43
|
+
marginRight: toPx(style.marginRight ?? style.marginHorizontal),
|
|
44
|
+
marginBlock: toPx(style.marginBlock),
|
|
45
|
+
marginBlockEnd: toPx(style.marginBlockEnd),
|
|
46
|
+
marginBlockStart: toPx(style.marginBlockStart),
|
|
47
|
+
marginInline: toPx(style.marginInline),
|
|
48
|
+
marginInlineEnd: toPx(style.marginInlineEnd ?? style.marginEnd),
|
|
49
|
+
marginInlineStart: toPx(style.marginInlineStart ?? style.marginStart),
|
|
50
|
+
|
|
51
|
+
// Padding - specific properties take precedence over shorthands (RN behavior)
|
|
52
|
+
padding: toPx(style.padding),
|
|
53
|
+
paddingTop: toPx(style.paddingTop ?? style.paddingVertical),
|
|
54
|
+
paddingBottom: toPx(style.paddingBottom ?? style.paddingVertical),
|
|
55
|
+
paddingLeft: toPx(style.paddingLeft ?? style.paddingHorizontal),
|
|
56
|
+
paddingRight: toPx(style.paddingRight ?? style.paddingHorizontal),
|
|
57
|
+
paddingBlock: toPx(style.paddingBlock),
|
|
58
|
+
paddingBlockEnd: toPx(style.paddingBlockEnd),
|
|
59
|
+
paddingBlockStart: toPx(style.paddingBlockStart),
|
|
60
|
+
paddingInline: toPx(style.paddingInline),
|
|
61
|
+
paddingInlineEnd: toPx(style.paddingInlineEnd ?? style.paddingEnd),
|
|
62
|
+
paddingInlineStart: toPx(style.paddingInlineStart ?? style.paddingStart),
|
|
63
|
+
|
|
64
|
+
// Border widths
|
|
65
|
+
borderInlineStartWidth: toPx(style.borderStartWidth),
|
|
66
|
+
borderInlineEndWidth: toPx(style.borderEndWidth),
|
|
67
|
+
borderWidth: toPx(style.borderWidth),
|
|
68
|
+
borderTopWidth: toPx(style.borderTopWidth),
|
|
69
|
+
borderBottomWidth: toPx(style.borderBottomWidth),
|
|
70
|
+
borderLeftWidth: toPx(style.borderLeftWidth),
|
|
71
|
+
borderRightWidth: toPx(style.borderRightWidth),
|
|
72
|
+
|
|
73
|
+
// Border radius (physical)
|
|
74
|
+
borderRadius: toPx(style.borderRadius),
|
|
75
|
+
borderTopLeftRadius: toPx(style.borderTopLeftRadius),
|
|
76
|
+
borderTopRightRadius: toPx(style.borderTopRightRadius),
|
|
77
|
+
borderBottomLeftRadius: toPx(style.borderBottomLeftRadius),
|
|
78
|
+
borderBottomRightRadius: toPx(style.borderBottomRightRadius),
|
|
79
|
+
|
|
80
|
+
// Border radius (logical)
|
|
81
|
+
borderStartStartRadius: toPx(
|
|
82
|
+
style.borderStartStartRadius ?? style.borderTopStartRadius
|
|
83
|
+
),
|
|
84
|
+
borderStartEndRadius: toPx(
|
|
85
|
+
style.borderStartEndRadius ?? style.borderTopEndRadius
|
|
86
|
+
),
|
|
87
|
+
borderEndStartRadius: toPx(
|
|
88
|
+
style.borderEndStartRadius ?? style.borderBottomStartRadius
|
|
89
|
+
),
|
|
90
|
+
borderEndEndRadius: toPx(
|
|
91
|
+
style.borderEndEndRadius ?? style.borderBottomEndRadius
|
|
92
|
+
),
|
|
93
|
+
|
|
94
|
+
// Border colors
|
|
95
|
+
borderColor: toColor(style.borderColor),
|
|
96
|
+
borderBlockColor: toColor(style.borderBlockColor),
|
|
97
|
+
borderBlockEndColor: toColor(style.borderBlockEndColor),
|
|
98
|
+
borderBlockStartColor: toColor(style.borderBlockStartColor),
|
|
99
|
+
borderBottomColor: toColor(style.borderBottomColor),
|
|
100
|
+
borderInlineEndColor: toColor(style.borderEndColor),
|
|
101
|
+
borderLeftColor: toColor(style.borderLeftColor),
|
|
102
|
+
borderRightColor: toColor(style.borderRightColor),
|
|
103
|
+
borderInlineStartColor: toColor(style.borderStartColor),
|
|
104
|
+
borderTopColor: toColor(style.borderTopColor),
|
|
105
|
+
borderStyle:
|
|
106
|
+
style.borderStyle ??
|
|
107
|
+
(style.borderWidth != null ||
|
|
108
|
+
style.borderTopWidth != null ||
|
|
109
|
+
style.borderBottomWidth != null ||
|
|
110
|
+
style.borderLeftWidth != null ||
|
|
111
|
+
style.borderRightWidth != null ||
|
|
112
|
+
style.borderStartWidth != null ||
|
|
113
|
+
style.borderEndWidth != null ||
|
|
114
|
+
style.borderColor != null
|
|
115
|
+
? 'solid'
|
|
116
|
+
: undefined),
|
|
117
|
+
|
|
118
|
+
// Typography
|
|
119
|
+
color: toColor(style.color),
|
|
120
|
+
fontFamily: style.fontFamily,
|
|
121
|
+
fontSize: toPx(style.fontSize),
|
|
122
|
+
fontStyle: style.fontStyle,
|
|
123
|
+
fontWeight: style.fontWeight,
|
|
124
|
+
lineHeight: toPx(style.lineHeight),
|
|
125
|
+
letterSpacing: toPx(style.letterSpacing),
|
|
126
|
+
|
|
127
|
+
// View appearance
|
|
128
|
+
backgroundColor: toColor(style.backgroundColor),
|
|
129
|
+
// boxShadow/filter: RN accepts arrays, CSS only strings
|
|
130
|
+
boxShadow:
|
|
131
|
+
typeof style.boxShadow === 'string' ? style.boxShadow : undefined,
|
|
132
|
+
display: style.display,
|
|
133
|
+
position: style.position,
|
|
134
|
+
alignSelf: style.alignSelf,
|
|
135
|
+
backfaceVisibility: style.backfaceVisibility,
|
|
136
|
+
cursor: style.cursor,
|
|
137
|
+
filter: typeof style.filter === 'string' ? style.filter : undefined,
|
|
138
|
+
mixBlendMode: style.mixBlendMode,
|
|
139
|
+
boxSizing: style.boxSizing,
|
|
140
|
+
// pointerEvents: RN 'box-none'/'box-only' have no CSS equivalent
|
|
141
|
+
pointerEvents:
|
|
142
|
+
style.pointerEvents === 'auto' || style.pointerEvents === 'none'
|
|
143
|
+
? style.pointerEvents
|
|
144
|
+
: undefined,
|
|
145
|
+
|
|
146
|
+
// Outline
|
|
147
|
+
outlineColor: toColor(style.outlineColor),
|
|
148
|
+
outlineStyle:
|
|
149
|
+
style.outlineStyle ?? (style.outlineWidth != null ? 'solid' : undefined),
|
|
150
|
+
outlineOffset: toPx(style.outlineOffset),
|
|
151
|
+
outlineWidth: toPx(style.outlineWidth),
|
|
152
|
+
|
|
153
|
+
// Transforms
|
|
154
|
+
transform: resolveTransform(style.transform),
|
|
155
|
+
// transformOrigin: RN accepts strings or arrays, CSS only strings
|
|
156
|
+
transformOrigin:
|
|
157
|
+
typeof style.transformOrigin === 'string'
|
|
158
|
+
? style.transformOrigin
|
|
159
|
+
: undefined,
|
|
160
|
+
|
|
161
|
+
// Flex
|
|
162
|
+
flex: style.flex,
|
|
163
|
+
flexGrow: style.flexGrow,
|
|
164
|
+
flexShrink: style.flexShrink,
|
|
165
|
+
flexBasis: toPx(style.flexBasis),
|
|
166
|
+
|
|
167
|
+
// Misc
|
|
168
|
+
zIndex: style.zIndex,
|
|
169
|
+
// opacity: RN AnimatableNumericValue includes AnimatedNode; CSS only number
|
|
170
|
+
opacity: typeof style.opacity === 'number' ? style.opacity : undefined,
|
|
171
|
+
aspectRatio: style.aspectRatio,
|
|
172
|
+
|
|
173
|
+
// Extra options
|
|
174
|
+
overflowY:
|
|
175
|
+
extraOptions.scrollEnabled != null
|
|
176
|
+
? extraOptions.scrollEnabled
|
|
177
|
+
? 'auto'
|
|
178
|
+
: 'hidden'
|
|
179
|
+
: undefined,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// Clean undefined values
|
|
183
|
+
return Object.fromEntries(
|
|
184
|
+
Object.entries(css).filter(([, v]) => v !== undefined)
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function toPx(
|
|
189
|
+
value?: DimensionValue | AnimatableNumericValue | string
|
|
190
|
+
): string | undefined {
|
|
191
|
+
if (value == null) return undefined;
|
|
192
|
+
if (typeof value === 'number') return `${value}px`;
|
|
193
|
+
if (typeof value === 'string') return value;
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function resolveTransform(
|
|
198
|
+
transform: EnrichedInputStyle['transform']
|
|
199
|
+
): string | undefined {
|
|
200
|
+
if (typeof transform === 'string') return transform;
|
|
201
|
+
if (!Array.isArray(transform)) return undefined;
|
|
202
|
+
|
|
203
|
+
const parts = transform.map((item) => {
|
|
204
|
+
if ('translateX' in item) return `translateX(${item.translateX}px)`;
|
|
205
|
+
if ('translateY' in item) return `translateY(${item.translateY}px)`;
|
|
206
|
+
if ('translateZ' in item) return `translateZ(${item.translateZ}px)`;
|
|
207
|
+
if ('scale' in item) return `scale(${item.scale})`;
|
|
208
|
+
if ('scaleX' in item) return `scaleX(${item.scaleX})`;
|
|
209
|
+
if ('scaleY' in item) return `scaleY(${item.scaleY})`;
|
|
210
|
+
if ('scaleZ' in item) return `scaleZ(${item.scaleZ})`;
|
|
211
|
+
if ('rotate' in item) return `rotate(${item.rotate})`;
|
|
212
|
+
if ('rotateX' in item) return `rotateX(${item.rotateX})`;
|
|
213
|
+
if ('rotateY' in item) return `rotateY(${item.rotateY})`;
|
|
214
|
+
if ('rotateZ' in item) return `rotateZ(${item.rotateZ})`;
|
|
215
|
+
if ('skewX' in item) return `skewX(${item.skewX})`;
|
|
216
|
+
if ('skewY' in item) return `skewY(${item.skewY})`;
|
|
217
|
+
if ('perspective' in item) return `perspective(${item.perspective}px)`;
|
|
218
|
+
if ('matrix' in item) {
|
|
219
|
+
return item.matrix.length === 16
|
|
220
|
+
? `matrix3d(${item.matrix.join(', ')})`
|
|
221
|
+
: `matrix(${item.matrix.join(', ')})`;
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const css = parts.filter(Boolean).join(' ');
|
|
227
|
+
return css || undefined;
|
|
228
|
+
}
|