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,84 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
import type { HtmlStyle } from '../../types';
|
|
3
|
+
import { HEADING_LEVELS, HEADING_TAGS } from './EnrichedHeading';
|
|
4
|
+
|
|
5
|
+
type ChainedCommands = ReturnType<Editor['chain']>;
|
|
6
|
+
|
|
7
|
+
export function isAnyParagraphFormatActive(editor: Editor): boolean {
|
|
8
|
+
return (
|
|
9
|
+
editor.isActive('blockquote') ||
|
|
10
|
+
editor.isActive('codeBlock') ||
|
|
11
|
+
HEADING_LEVELS.some((level) => editor.isActive('heading', { level })) ||
|
|
12
|
+
editor.isActive('orderedList') ||
|
|
13
|
+
editor.isActive('unorderedList') ||
|
|
14
|
+
editor.isActive('checkboxList')
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function isLinkBlocked(editor: Editor): boolean {
|
|
19
|
+
return (
|
|
20
|
+
editor.isActive('code') ||
|
|
21
|
+
editor.isActive('codeBlock') ||
|
|
22
|
+
editor.isActive('mention') ||
|
|
23
|
+
editor.isActive('image')
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
function isMentionBlocked(editor: Editor): boolean {
|
|
27
|
+
return (
|
|
28
|
+
editor.isActive('code') ||
|
|
29
|
+
editor.isActive('codeBlock') ||
|
|
30
|
+
editor.isActive('link') ||
|
|
31
|
+
editor.isActive('image')
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isImageBlocked(editor: Editor): boolean {
|
|
36
|
+
return (
|
|
37
|
+
editor.isActive('code') ||
|
|
38
|
+
editor.isActive('link') ||
|
|
39
|
+
editor.isActive('mention')
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function isFormatBlocked(
|
|
44
|
+
tiptapName: string,
|
|
45
|
+
editor: Editor,
|
|
46
|
+
htmlStyle: Required<HtmlStyle>
|
|
47
|
+
): boolean {
|
|
48
|
+
if (tiptapName === 'image') {
|
|
49
|
+
return isImageBlocked(editor);
|
|
50
|
+
}
|
|
51
|
+
if (tiptapName === 'link') {
|
|
52
|
+
return isLinkBlocked(editor);
|
|
53
|
+
}
|
|
54
|
+
if (tiptapName === 'code' && editor.isActive('image')) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (tiptapName === 'mention') {
|
|
59
|
+
return isMentionBlocked(editor);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (editor.isActive('codeBlock')) {
|
|
63
|
+
return ['bold', 'italic', 'underline', 'strike', 'code'].includes(
|
|
64
|
+
tiptapName
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
for (const level of HEADING_LEVELS) {
|
|
68
|
+
if (editor.isActive('heading', { level })) {
|
|
69
|
+
const key = HEADING_TAGS[level - 1]!;
|
|
70
|
+
if (tiptapName === 'bold' && htmlStyle[key].bold) return true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function toggleParagraphFormat(
|
|
77
|
+
isActive: () => boolean,
|
|
78
|
+
deactivate: () => boolean,
|
|
79
|
+
activate: (c: ChainedCommands) => ChainedCommands,
|
|
80
|
+
chain: () => ChainedCommands
|
|
81
|
+
): boolean {
|
|
82
|
+
if (isActive()) return deactivate();
|
|
83
|
+
return activate(chain().clearNodes()).run();
|
|
84
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isTextSelection, type Editor, type JSONContent } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
import { lineStartBackspace } from './wrappedBlockKeyboard';
|
|
4
|
+
|
|
5
|
+
function emptyListItemContent(itemName: string): JSONContent {
|
|
6
|
+
return {
|
|
7
|
+
type: itemName,
|
|
8
|
+
content: [{ type: 'paragraph' }],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Enter: always extend the list — splitListItem fails on an empty last item (see TipTap splitListItem).
|
|
13
|
+
export function listEnter(editor: Editor, itemName: string): boolean {
|
|
14
|
+
if (!editor.isActive(itemName)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (editor.chain().focus().splitListItem(itemName).scrollIntoView().run()) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const { selection } = editor.state;
|
|
22
|
+
if (!selection.empty || !isTextSelection(selection)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const $from = selection.$from;
|
|
27
|
+
if ($from.parent.content.size > 0) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Flat lists only: list item is always the parent block of the paragraph (depth − 1).
|
|
32
|
+
const itemDepth = $from.depth - 1;
|
|
33
|
+
if (itemDepth < 1) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const insertPos = $from.after(itemDepth);
|
|
37
|
+
|
|
38
|
+
return editor
|
|
39
|
+
.chain()
|
|
40
|
+
.focus()
|
|
41
|
+
.insertContentAt(insertPos, emptyListItemContent(itemName))
|
|
42
|
+
.scrollIntoView()
|
|
43
|
+
.run();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Backspace: first press at line start lifts the list item; second press (paragraph below list) joins backward.
|
|
47
|
+
export function listBackspace(
|
|
48
|
+
editor: Editor,
|
|
49
|
+
itemName: string,
|
|
50
|
+
wrapperNames: readonly string[]
|
|
51
|
+
): boolean {
|
|
52
|
+
return lineStartBackspace(editor, {
|
|
53
|
+
isActive: () => editor.isActive(itemName),
|
|
54
|
+
lift: () => editor.chain().focus().liftListItem(itemName).run(),
|
|
55
|
+
shouldJoinBefore: (beforeName) =>
|
|
56
|
+
beforeName != null && wrapperNames.includes(beforeName),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { isTextSelection, type Editor } from '@tiptap/core';
|
|
2
|
+
import type { ResolvedPos } from '@tiptap/pm/model';
|
|
3
|
+
|
|
4
|
+
// Same as prosemirror-commands `findCutBefore` (not exported from that package)
|
|
5
|
+
// Resolves to the gap between this block and the block above it.
|
|
6
|
+
export function findCutBefore($pos: ResolvedPos): ResolvedPos | null {
|
|
7
|
+
if (!$pos.parent.type.spec.isolating) {
|
|
8
|
+
for (let i = $pos.depth - 1; i >= 0; i--) {
|
|
9
|
+
if ($pos.index(i) > 0) {
|
|
10
|
+
return $pos.doc.resolve($pos.before(i + 1));
|
|
11
|
+
}
|
|
12
|
+
if ($pos.node(i).type.spec.isolating) {
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Line start → lift current block or join with the block above (wrapped blocks + lists). */
|
|
21
|
+
export function lineStartBackspace(
|
|
22
|
+
editor: Editor,
|
|
23
|
+
options: {
|
|
24
|
+
isActive: () => boolean;
|
|
25
|
+
lift: () => boolean;
|
|
26
|
+
shouldJoinBefore: (nodeNameBefore: string | undefined) => boolean;
|
|
27
|
+
}
|
|
28
|
+
): boolean {
|
|
29
|
+
const { selection } = editor.state;
|
|
30
|
+
|
|
31
|
+
if (
|
|
32
|
+
!isTextSelection(selection) ||
|
|
33
|
+
!selection.$cursor ||
|
|
34
|
+
selection.$cursor.parentOffset !== 0
|
|
35
|
+
) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (options.isActive()) {
|
|
40
|
+
return options.lift();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const $cut = findCutBefore(selection.$cursor);
|
|
44
|
+
const beforeName = $cut?.nodeBefore?.type.name;
|
|
45
|
+
if (options.shouldJoinBefore(beforeName)) {
|
|
46
|
+
return editor.chain().focus().joinTextblockBackward().run();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Enter only splits inside the wrapper so the default handler does not exit the block.
|
|
53
|
+
export function wrappedBlockEnter(
|
|
54
|
+
editor: Editor,
|
|
55
|
+
wrapperNodeName: string
|
|
56
|
+
): boolean {
|
|
57
|
+
if (editor.isActive(wrapperNodeName)) {
|
|
58
|
+
return editor.commands.splitBlock();
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Backspace at line start inside the wrapper lifts the current paragraph out.
|
|
64
|
+
// Backspace at line start in a paragraph below the wrapper uses `joinTextblockBackward`
|
|
65
|
+
// so default `joinBackward` / `deleteBarrier` does not re-wrap the paragraph into the
|
|
66
|
+
// wrapper above.
|
|
67
|
+
export function wrappedBlockBackspace(
|
|
68
|
+
editor: Editor,
|
|
69
|
+
wrapperNodeName: string
|
|
70
|
+
): boolean {
|
|
71
|
+
return lineStartBackspace(editor, {
|
|
72
|
+
isActive: () => editor.isActive(wrapperNodeName),
|
|
73
|
+
lift: () => editor.chain().focus().lift(wrapperNodeName).run(),
|
|
74
|
+
shouldJoinBefore: (beforeName) => beforeName === wrapperNodeName,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect image `File`s from the clipboard and build `OnPasteImagesEvent` payloads with `blob:` URIs.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Editor } from '@tiptap/react';
|
|
6
|
+
import type { NativeSyntheticEvent } from 'react-native';
|
|
7
|
+
|
|
8
|
+
import type { OnPasteImagesEvent } from '../types';
|
|
9
|
+
import { adaptWebToNativeEvent } from './adaptWebToNativeEvent';
|
|
10
|
+
import { isImageBlocked } from './formats/formatRules';
|
|
11
|
+
import { readImageDimensionsFromBlob } from './pastedImageDimensions';
|
|
12
|
+
|
|
13
|
+
const isImageLikeClipboardFile = (file: File, reportedMime: string) =>
|
|
14
|
+
reportedMime.startsWith('image/') || file.type.startsWith('image/');
|
|
15
|
+
|
|
16
|
+
/** Browsers often expose the same paste as two `File`s (items vs files) with different `name`. */
|
|
17
|
+
function dedupeImageFiles(files: File[]): File[] {
|
|
18
|
+
const seen = new Set<string>();
|
|
19
|
+
const out: File[] = [];
|
|
20
|
+
for (const file of files) {
|
|
21
|
+
const key = `${file.size}\0${file.lastModified}\0${file.type}`;
|
|
22
|
+
if (seen.has(key)) continue;
|
|
23
|
+
seen.add(key);
|
|
24
|
+
out.push(file);
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function clipboardImageFiles(data: DataTransfer): File[] {
|
|
30
|
+
const fromItems: File[] = [];
|
|
31
|
+
for (const item of [...data.items]) {
|
|
32
|
+
if (item == null || item.kind !== 'file') continue;
|
|
33
|
+
const file = item.getAsFile();
|
|
34
|
+
if (!file) continue;
|
|
35
|
+
if (isImageLikeClipboardFile(file, item.type)) fromItems.push(file);
|
|
36
|
+
}
|
|
37
|
+
if (fromItems.length > 0) return dedupeImageFiles(fromItems);
|
|
38
|
+
|
|
39
|
+
const fromFiles: File[] = [];
|
|
40
|
+
for (const file of [...data.files]) {
|
|
41
|
+
if (isImageLikeClipboardFile(file, file.type)) fromFiles.push(file);
|
|
42
|
+
}
|
|
43
|
+
return dedupeImageFiles(fromFiles);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function buildPasteImagesPayload(
|
|
47
|
+
files: File[]
|
|
48
|
+
): Promise<OnPasteImagesEvent['images']> {
|
|
49
|
+
return Promise.all(
|
|
50
|
+
files.map(async (file) => {
|
|
51
|
+
const uri = URL.createObjectURL(file);
|
|
52
|
+
const { width, height } = await readImageDimensionsFromBlob(file, uri);
|
|
53
|
+
return {
|
|
54
|
+
uri,
|
|
55
|
+
type: file.type || 'image/png',
|
|
56
|
+
width,
|
|
57
|
+
height,
|
|
58
|
+
};
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function handleClipboardPasteImages(
|
|
64
|
+
event: ClipboardEvent,
|
|
65
|
+
getEditor: () => Editor | null,
|
|
66
|
+
getOnPasteImages: () =>
|
|
67
|
+
| ((e: NativeSyntheticEvent<OnPasteImagesEvent>) => void)
|
|
68
|
+
| undefined
|
|
69
|
+
): boolean {
|
|
70
|
+
const clipboardData = event.clipboardData;
|
|
71
|
+
if (!clipboardData) return false;
|
|
72
|
+
|
|
73
|
+
const files = clipboardImageFiles(clipboardData);
|
|
74
|
+
if (files.length === 0) return false;
|
|
75
|
+
|
|
76
|
+
const ed = getEditor();
|
|
77
|
+
if (!ed || isImageBlocked(ed)) return false;
|
|
78
|
+
|
|
79
|
+
const onPasteImages = getOnPasteImages();
|
|
80
|
+
if (!onPasteImages) return false;
|
|
81
|
+
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
|
|
84
|
+
(async () => {
|
|
85
|
+
try {
|
|
86
|
+
const images = await buildPasteImagesPayload(files);
|
|
87
|
+
const editor = getEditor();
|
|
88
|
+
if (!editor || isImageBlocked(editor)) return;
|
|
89
|
+
onPasteImages(adaptWebToNativeEvent(event, { images }));
|
|
90
|
+
} catch (err) {
|
|
91
|
+
console.error(err);
|
|
92
|
+
}
|
|
93
|
+
})();
|
|
94
|
+
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort intrinsic pixel size for pasted images (from Blob, with URL fallback).
|
|
3
|
+
* Returns 0×0 when decode fails (caller still emits onPasteImages).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export async function readImageDimensionsFromBlob(
|
|
7
|
+
blob: Blob,
|
|
8
|
+
fallbackUrl: string
|
|
9
|
+
): Promise<{ width: number; height: number }> {
|
|
10
|
+
try {
|
|
11
|
+
const bitmap = await createImageBitmap(blob);
|
|
12
|
+
const { width, height } = bitmap;
|
|
13
|
+
bitmap.close();
|
|
14
|
+
return { width, height };
|
|
15
|
+
} catch {
|
|
16
|
+
return tryImageElementDimensions(fallbackUrl);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function tryImageElementDimensions(
|
|
21
|
+
url: string
|
|
22
|
+
): Promise<{ width: number; height: number }> {
|
|
23
|
+
return new Promise((resolve) => {
|
|
24
|
+
if (typeof Image === 'undefined') {
|
|
25
|
+
resolve({ width: 0, height: 0 });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const img = new Image();
|
|
29
|
+
img.onload = () => {
|
|
30
|
+
const w = img.naturalWidth;
|
|
31
|
+
const h = img.naturalHeight;
|
|
32
|
+
resolve({
|
|
33
|
+
width: Number.isFinite(w) ? w : 0,
|
|
34
|
+
height: Number.isFinite(h) ? h : 0,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
img.onerror = () => resolve({ width: 0, height: 0 });
|
|
38
|
+
img.src = url;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { Slice } from '@tiptap/pm/model';
|
|
3
|
+
import { Plugin } from '@tiptap/pm/state';
|
|
4
|
+
import { makeMentionPluginState } from './makeMentionPluginState';
|
|
5
|
+
import { mentionPluginKey } from './mentionPluginKey';
|
|
6
|
+
import { removeMentionMarksIfSpansResized } from './removeMentionMarksIfSpansResized';
|
|
7
|
+
import { stripPartialMentionMarks } from './stripPartialMentionMarks';
|
|
8
|
+
import type { MentionPluginOptions, TriggerState } from './types';
|
|
9
|
+
|
|
10
|
+
export type { MentionPluginOptions, TriggerState } from './types';
|
|
11
|
+
export { mentionPluginKey } from './mentionPluginKey';
|
|
12
|
+
export { setMention } from './setMention';
|
|
13
|
+
export { startMention } from './startMention';
|
|
14
|
+
export { subscribeMentionEvents } from './subscribeMentionEvents';
|
|
15
|
+
|
|
16
|
+
export const MentionPlugin = Extension.create<MentionPluginOptions>({
|
|
17
|
+
name: 'mentionTrigger',
|
|
18
|
+
addOptions() {
|
|
19
|
+
return {
|
|
20
|
+
getIndicators: () => {
|
|
21
|
+
throw new Error(
|
|
22
|
+
'MentionPlugin.configure({ getIndicators }) is required'
|
|
23
|
+
);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
addProseMirrorPlugins() {
|
|
28
|
+
return [
|
|
29
|
+
new Plugin<TriggerState>({
|
|
30
|
+
key: mentionPluginKey,
|
|
31
|
+
props: {
|
|
32
|
+
transformPasted(slice: Slice): Slice {
|
|
33
|
+
return new Slice(
|
|
34
|
+
stripPartialMentionMarks(slice.content),
|
|
35
|
+
slice.openStart,
|
|
36
|
+
slice.openEnd
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
state: makeMentionPluginState(this.options.getIndicators),
|
|
41
|
+
appendTransaction: removeMentionMarksIfSpansResized,
|
|
42
|
+
}),
|
|
43
|
+
];
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { findParentNodeClosestToPos } from '@tiptap/core';
|
|
2
|
+
import type { ResolvedPos, Schema } from '@tiptap/pm/model';
|
|
3
|
+
import { EXCLUDED_MARKS as EXCLUDED_MARKS_BY_MENTION } from '../../formats/EnrichedMention';
|
|
4
|
+
|
|
5
|
+
export function isCaretInBlockedContext(
|
|
6
|
+
$from: ResolvedPos,
|
|
7
|
+
schema: Schema
|
|
8
|
+
): boolean {
|
|
9
|
+
for (const excludedMark of EXCLUDED_MARKS_BY_MENTION) {
|
|
10
|
+
if (schema.marks[excludedMark]?.isInSet($from.marks())) return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
findParentNodeClosestToPos($from, (n) => n.type.name === 'codeBlock') !=
|
|
15
|
+
null
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { StateField } from '@tiptap/pm/state';
|
|
2
|
+
import { isCaretInBlockedContext } from './isCaretInBlockedContext';
|
|
3
|
+
import type { MentionPluginOptions, TriggerState } from './types';
|
|
4
|
+
|
|
5
|
+
export function makeMentionPluginState(
|
|
6
|
+
getIndicators: MentionPluginOptions['getIndicators']
|
|
7
|
+
): StateField<TriggerState> {
|
|
8
|
+
return {
|
|
9
|
+
init(): TriggerState {
|
|
10
|
+
return { active: false };
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
apply(_tr, _prev, _old, newEditorState): TriggerState {
|
|
14
|
+
const { selection } = newEditorState;
|
|
15
|
+
if (!selection.empty) return { active: false };
|
|
16
|
+
|
|
17
|
+
const $from = selection.$from;
|
|
18
|
+
if (isCaretInBlockedContext($from, newEditorState.schema))
|
|
19
|
+
return { active: false };
|
|
20
|
+
|
|
21
|
+
const blockStart = $from.start();
|
|
22
|
+
const text = newEditorState.doc.textBetween(
|
|
23
|
+
blockStart,
|
|
24
|
+
$from.pos,
|
|
25
|
+
'\n',
|
|
26
|
+
'\n'
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const mentionType = newEditorState.schema.marks.mention;
|
|
30
|
+
const indicators = getIndicators();
|
|
31
|
+
const found = findLastValidMentionIndicator(text, indicators, (idx) => {
|
|
32
|
+
if (!mentionType) return false;
|
|
33
|
+
const $at = newEditorState.doc.resolve(blockStart + idx + 1);
|
|
34
|
+
return Boolean(mentionType.isInSet($at.marks()));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (!found) return { active: false };
|
|
38
|
+
|
|
39
|
+
const query = text.slice(found.indexInText + 1);
|
|
40
|
+
|
|
41
|
+
// Native platforms end the trigger after two spaces in the query.
|
|
42
|
+
if ((query.match(/ /g) ?? []).length >= 2) return { active: false };
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
active: true,
|
|
46
|
+
indicator: found.indicator,
|
|
47
|
+
from: blockStart + found.indexInText,
|
|
48
|
+
to: $from.pos,
|
|
49
|
+
query,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function findLastValidMentionIndicator(
|
|
56
|
+
text: string,
|
|
57
|
+
indicators: readonly string[],
|
|
58
|
+
isIndicatorInsideFinalizedMention: (indexInText: number) => boolean
|
|
59
|
+
): { indexInText: number; indicator: string } | null {
|
|
60
|
+
for (let idx = text.length - 1; idx >= 0; idx--) {
|
|
61
|
+
const ch = text[idx];
|
|
62
|
+
if (!ch || !indicators.includes(ch)) continue;
|
|
63
|
+
|
|
64
|
+
const isAtStart = idx === 0;
|
|
65
|
+
const isAfterSpace = idx > 0 && text[idx - 1] === ' ';
|
|
66
|
+
if (!isAtStart && !isAfterSpace) continue;
|
|
67
|
+
|
|
68
|
+
// Skip indicators inside a finalized mention
|
|
69
|
+
if (isIndicatorInsideFinalizedMention(idx)) continue;
|
|
70
|
+
|
|
71
|
+
return { indexInText: idx, indicator: ch };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Mark, MarkType, Node } from '@tiptap/pm/model';
|
|
2
|
+
import type { EditorState, Transaction } from '@tiptap/pm/state';
|
|
3
|
+
|
|
4
|
+
export type MentionMarkRange = { from: number; to: number; mark: Mark };
|
|
5
|
+
|
|
6
|
+
export function removeMentionMarksIfSpansResized(
|
|
7
|
+
transactions: readonly Transaction[],
|
|
8
|
+
oldState: EditorState,
|
|
9
|
+
newState: EditorState
|
|
10
|
+
): Transaction | null {
|
|
11
|
+
if (!transactions.some((tr) => tr.docChanged)) return null;
|
|
12
|
+
|
|
13
|
+
const mentionType = newState.schema.marks.mention;
|
|
14
|
+
if (!mentionType) return null;
|
|
15
|
+
|
|
16
|
+
const merged = mergeContiguousSameMarkRanges(
|
|
17
|
+
collectMentionMarkRanges(oldState.doc, mentionType)
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const tr = newState.tr;
|
|
21
|
+
let changed = false;
|
|
22
|
+
|
|
23
|
+
for (const { from, to, mark } of merged) {
|
|
24
|
+
const origLen = to - from;
|
|
25
|
+
let newFrom = from;
|
|
26
|
+
let newTo = to;
|
|
27
|
+
|
|
28
|
+
for (const t of transactions) {
|
|
29
|
+
newFrom = t.mapping.map(newFrom, 1);
|
|
30
|
+
newTo = t.mapping.map(newTo, -1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (newTo - newFrom !== origLen) {
|
|
34
|
+
tr.removeMark(newFrom, newTo, mark.type);
|
|
35
|
+
changed = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return changed ? tr : null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function collectMentionMarkRanges(
|
|
43
|
+
doc: Node,
|
|
44
|
+
mentionType: MarkType
|
|
45
|
+
): MentionMarkRange[] {
|
|
46
|
+
const ranges: MentionMarkRange[] = [];
|
|
47
|
+
doc.descendants((node, pos) => {
|
|
48
|
+
if (!node.isText) return;
|
|
49
|
+
const m = mentionType.isInSet(node.marks);
|
|
50
|
+
if (m) ranges.push({ from: pos, to: pos + node.nodeSize, mark: m });
|
|
51
|
+
});
|
|
52
|
+
return ranges;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function mergeContiguousSameMarkRanges(
|
|
56
|
+
ranges: MentionMarkRange[]
|
|
57
|
+
): MentionMarkRange[] {
|
|
58
|
+
const merged: MentionMarkRange[] = [];
|
|
59
|
+
for (const range of ranges) {
|
|
60
|
+
const prev = merged[merged.length - 1];
|
|
61
|
+
if (prev && prev.mark === range.mark && prev.to === range.from) {
|
|
62
|
+
prev.to = range.to;
|
|
63
|
+
} else {
|
|
64
|
+
merged.push({ ...range });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return merged;
|
|
68
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Fragment } from '@tiptap/pm/model';
|
|
2
|
+
import type { EditorState } from '@tiptap/pm/state';
|
|
3
|
+
import type { Editor } from '@tiptap/react';
|
|
4
|
+
import { isCaretInBlockedContext } from './isCaretInBlockedContext';
|
|
5
|
+
import { mentionPluginKey } from './mentionPluginKey';
|
|
6
|
+
|
|
7
|
+
// Insert a mention mark at the current active trigger range.
|
|
8
|
+
export function setMention(
|
|
9
|
+
editor: Editor,
|
|
10
|
+
indicator: string,
|
|
11
|
+
text: string,
|
|
12
|
+
attributes?: Record<string, string>
|
|
13
|
+
): void {
|
|
14
|
+
const { state } = editor;
|
|
15
|
+
const triggerState = mentionPluginKey.getState(state);
|
|
16
|
+
|
|
17
|
+
if (!triggerState?.active) {
|
|
18
|
+
console.warn(
|
|
19
|
+
'[EnrichedMention] setMention called but there is no active mention trigger'
|
|
20
|
+
);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const mentionType = state.schema.marks.mention;
|
|
25
|
+
if (!mentionType) return;
|
|
26
|
+
|
|
27
|
+
const $from = state.selection.$from;
|
|
28
|
+
if (isCaretInBlockedContext($from, state.schema)) {
|
|
29
|
+
console.warn(
|
|
30
|
+
'[EnrichedMention] setMention called but caret is inside a blocked context'
|
|
31
|
+
);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const { from, to } = triggerState;
|
|
36
|
+
|
|
37
|
+
const extendedTo = Math.max(
|
|
38
|
+
to,
|
|
39
|
+
exclusiveEndThroughMatchingMentionTail(state, from, text)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const mentionMark = mentionType.create({
|
|
43
|
+
indicator,
|
|
44
|
+
text,
|
|
45
|
+
attributes: attributes ?? {},
|
|
46
|
+
});
|
|
47
|
+
const baseMarks = state.doc
|
|
48
|
+
.resolve(from)
|
|
49
|
+
.marks()
|
|
50
|
+
.filter((m) => m.type.name !== 'mention');
|
|
51
|
+
const fragment = Fragment.fromArray([
|
|
52
|
+
state.schema.text(text, mentionMark.addToSet(baseMarks)),
|
|
53
|
+
state.schema.text(' ', baseMarks),
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
editor
|
|
57
|
+
.chain()
|
|
58
|
+
.focus()
|
|
59
|
+
.command(({ tr }) => {
|
|
60
|
+
tr.replaceWith(from, extendedTo, fragment);
|
|
61
|
+
return true;
|
|
62
|
+
})
|
|
63
|
+
.run();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// If the user moved the caret back into a partial match, extend `to` over the
|
|
67
|
+
// matching tail to avoid leftover characters after the inserted mention.
|
|
68
|
+
function exclusiveEndThroughMatchingMentionTail(
|
|
69
|
+
state: EditorState,
|
|
70
|
+
from: number,
|
|
71
|
+
text: string
|
|
72
|
+
): number {
|
|
73
|
+
const parentEnd = state.doc.resolve(from).end();
|
|
74
|
+
let scanPos = from;
|
|
75
|
+
for (const ch of text) {
|
|
76
|
+
const end = scanPos + ch.length;
|
|
77
|
+
if (end > parentEnd || state.doc.textBetween(scanPos, end, '') !== ch) {
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
scanPos = end;
|
|
81
|
+
}
|
|
82
|
+
return scanPos;
|
|
83
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/react';
|
|
2
|
+
|
|
3
|
+
export function startMention(
|
|
4
|
+
editor: Editor,
|
|
5
|
+
indicator: string,
|
|
6
|
+
indicators: string[]
|
|
7
|
+
): void {
|
|
8
|
+
if (!indicators.includes(indicator)) {
|
|
9
|
+
console.warn(
|
|
10
|
+
`[EnrichedMention] startMention: "${indicator}" is not in mentionIndicators`
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
editor.chain().focus().insertContent(indicator).run();
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Fragment } from '@tiptap/pm/model';
|
|
2
|
+
import type { Node } from '@tiptap/pm/model';
|
|
3
|
+
|
|
4
|
+
export function stripPartialMentionMarks(fragment: Fragment): Fragment {
|
|
5
|
+
const nodes: Node[] = [];
|
|
6
|
+
fragment.forEach((node) =>
|
|
7
|
+
nodes.push(
|
|
8
|
+
node.isText
|
|
9
|
+
? node.mark(
|
|
10
|
+
node.marks.filter(
|
|
11
|
+
(m) =>
|
|
12
|
+
m.type.name !== 'mention' ||
|
|
13
|
+
node.text === (m.attrs.text as string)
|
|
14
|
+
)
|
|
15
|
+
)
|
|
16
|
+
: node.copy(stripPartialMentionMarks(node.content))
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
return Fragment.from(nodes);
|
|
20
|
+
}
|