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,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Collect image `File`s from the clipboard and build `OnPasteImagesEvent` payloads with `blob:` URIs.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { adaptWebToNativeEvent } from "./adaptWebToNativeEvent.js";
|
|
8
|
+
import { isImageBlocked } from "./formats/formatRules.js";
|
|
9
|
+
import { readImageDimensionsFromBlob } from "./pastedImageDimensions.js";
|
|
10
|
+
const isImageLikeClipboardFile = (file, reportedMime) => reportedMime.startsWith('image/') || file.type.startsWith('image/');
|
|
11
|
+
|
|
12
|
+
/** Browsers often expose the same paste as two `File`s (items vs files) with different `name`. */
|
|
13
|
+
function dedupeImageFiles(files) {
|
|
14
|
+
const seen = new Set();
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const file of files) {
|
|
17
|
+
const key = `${file.size}\0${file.lastModified}\0${file.type}`;
|
|
18
|
+
if (seen.has(key)) continue;
|
|
19
|
+
seen.add(key);
|
|
20
|
+
out.push(file);
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
export function clipboardImageFiles(data) {
|
|
25
|
+
const fromItems = [];
|
|
26
|
+
for (const item of [...data.items]) {
|
|
27
|
+
if (item == null || item.kind !== 'file') continue;
|
|
28
|
+
const file = item.getAsFile();
|
|
29
|
+
if (!file) continue;
|
|
30
|
+
if (isImageLikeClipboardFile(file, item.type)) fromItems.push(file);
|
|
31
|
+
}
|
|
32
|
+
if (fromItems.length > 0) return dedupeImageFiles(fromItems);
|
|
33
|
+
const fromFiles = [];
|
|
34
|
+
for (const file of [...data.files]) {
|
|
35
|
+
if (isImageLikeClipboardFile(file, file.type)) fromFiles.push(file);
|
|
36
|
+
}
|
|
37
|
+
return dedupeImageFiles(fromFiles);
|
|
38
|
+
}
|
|
39
|
+
export async function buildPasteImagesPayload(files) {
|
|
40
|
+
return Promise.all(files.map(async file => {
|
|
41
|
+
const uri = URL.createObjectURL(file);
|
|
42
|
+
const {
|
|
43
|
+
width,
|
|
44
|
+
height
|
|
45
|
+
} = await readImageDimensionsFromBlob(file, uri);
|
|
46
|
+
return {
|
|
47
|
+
uri,
|
|
48
|
+
type: file.type || 'image/png',
|
|
49
|
+
width,
|
|
50
|
+
height
|
|
51
|
+
};
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
export function handleClipboardPasteImages(event, getEditor, getOnPasteImages) {
|
|
55
|
+
const clipboardData = event.clipboardData;
|
|
56
|
+
if (!clipboardData) return false;
|
|
57
|
+
const files = clipboardImageFiles(clipboardData);
|
|
58
|
+
if (files.length === 0) return false;
|
|
59
|
+
const ed = getEditor();
|
|
60
|
+
if (!ed || isImageBlocked(ed)) return false;
|
|
61
|
+
const onPasteImages = getOnPasteImages();
|
|
62
|
+
if (!onPasteImages) return false;
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
(async () => {
|
|
65
|
+
try {
|
|
66
|
+
const images = await buildPasteImagesPayload(files);
|
|
67
|
+
const editor = getEditor();
|
|
68
|
+
if (!editor || isImageBlocked(editor)) return;
|
|
69
|
+
onPasteImages(adaptWebToNativeEvent(event, {
|
|
70
|
+
images
|
|
71
|
+
}));
|
|
72
|
+
} catch (err) {
|
|
73
|
+
console.error(err);
|
|
74
|
+
}
|
|
75
|
+
})();
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=pasteImages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["adaptWebToNativeEvent","isImageBlocked","readImageDimensionsFromBlob","isImageLikeClipboardFile","file","reportedMime","startsWith","type","dedupeImageFiles","files","seen","Set","out","key","size","lastModified","has","add","push","clipboardImageFiles","data","fromItems","item","items","kind","getAsFile","length","fromFiles","buildPasteImagesPayload","Promise","all","map","uri","URL","createObjectURL","width","height","handleClipboardPasteImages","event","getEditor","getOnPasteImages","clipboardData","ed","onPasteImages","preventDefault","images","editor","err","console","error"],"sourceRoot":"../../../src","sources":["web/pasteImages.ts"],"mappings":";;AAAA;AACA;AACA;;AAMA,SAASA,qBAAqB,QAAQ,4BAAyB;AAC/D,SAASC,cAAc,QAAQ,0BAAuB;AACtD,SAASC,2BAA2B,QAAQ,4BAAyB;AAErE,MAAMC,wBAAwB,GAAGA,CAACC,IAAU,EAAEC,YAAoB,KAChEA,YAAY,CAACC,UAAU,CAAC,QAAQ,CAAC,IAAIF,IAAI,CAACG,IAAI,CAACD,UAAU,CAAC,QAAQ,CAAC;;AAErE;AACA,SAASE,gBAAgBA,CAACC,KAAa,EAAU;EAC/C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;EAC9B,MAAMC,GAAW,GAAG,EAAE;EACtB,KAAK,MAAMR,IAAI,IAAIK,KAAK,EAAE;IACxB,MAAMI,GAAG,GAAG,GAAGT,IAAI,CAACU,IAAI,KAAKV,IAAI,CAACW,YAAY,KAAKX,IAAI,CAACG,IAAI,EAAE;IAC9D,IAAIG,IAAI,CAACM,GAAG,CAACH,GAAG,CAAC,EAAE;IACnBH,IAAI,CAACO,GAAG,CAACJ,GAAG,CAAC;IACbD,GAAG,CAACM,IAAI,CAAC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K;MACLC;IACF,CAAC;EACH,CAAC,CACH,CAAC;AACH;AAEA,OAAO,SAASC,0BAA0BA,CACxCC,KAAqB,EACrBC,SAA8B,EAC9BC,gBAEa,EACJ;EACT,MAAMC,aAAa,GAAGH,KAAK,CAACG,aAAa;EACzC,IAAI,CAACA,aAAa,EAAE,OAAO,KAAK;EAEhC,MAAMhC,KAAK,GAAGU,mBAAmB,CAACsB,aAAa,CAAC;EAChD,IAAIhC,KAAK,CAACiB,MAAM,KAAK,CAAC,EAAE,OAAO,KAAK;EAEpC,MAAMgB,EAAE,GAAGH,SAAS,CAAC,CAAC;EACtB,IAAI,CAACG,EAAE,IAAIzC,cAAc,CAACyC,EAAE,CAAC,EAAE,OAAO,KAAK;EAE3C,MAAMC,aAAa,GAAGH,gBAAgB,CAAC,CAAC;EACxC,IAAI,CAACG,aAAa,EAAE,OAAO,KAAK;EAEhCL,KAAK,CAACM,cAAc,CAAC,CAAC;EAEtB,CAAC,YAAY;IACX,IAAI;MACF,MAAMC,MAAM,GAAG,MAAMjB,uBAAuB,CAACnB,KAAK,CAAC;MACnD,MAAMqC,MAAM,GAAGP,SAAS,CAAC,CAAC;MAC1B,IAAI,CAACO,MAAM,IAAI7C,cAAc,CAAC6C,MAAM,CAAC,EAAE;MACvCH,aAAa,CAAC3C,qBAAqB,CAACsC,KAAK,EAAE;QAAEO;MAAO,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,OAAOE,GAAG,EAAE;MACZC,OAAO,CAACC,KAAK,CAACF,GAAG,CAAC;IACpB;EACF,CAAC,EAAE,CAAC;EAEJ,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Best-effort intrinsic pixel size for pasted images (from Blob, with URL fallback).
|
|
5
|
+
* Returns 0×0 when decode fails (caller still emits onPasteImages).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export async function readImageDimensionsFromBlob(blob, fallbackUrl) {
|
|
9
|
+
try {
|
|
10
|
+
const bitmap = await createImageBitmap(blob);
|
|
11
|
+
const {
|
|
12
|
+
width,
|
|
13
|
+
height
|
|
14
|
+
} = bitmap;
|
|
15
|
+
bitmap.close();
|
|
16
|
+
return {
|
|
17
|
+
width,
|
|
18
|
+
height
|
|
19
|
+
};
|
|
20
|
+
} catch {
|
|
21
|
+
return tryImageElementDimensions(fallbackUrl);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function tryImageElementDimensions(url) {
|
|
25
|
+
return new Promise(resolve => {
|
|
26
|
+
if (typeof Image === 'undefined') {
|
|
27
|
+
resolve({
|
|
28
|
+
width: 0,
|
|
29
|
+
height: 0
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const img = new Image();
|
|
34
|
+
img.onload = () => {
|
|
35
|
+
const w = img.naturalWidth;
|
|
36
|
+
const h = img.naturalHeight;
|
|
37
|
+
resolve({
|
|
38
|
+
width: Number.isFinite(w) ? w : 0,
|
|
39
|
+
height: Number.isFinite(h) ? h : 0
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
img.onerror = () => resolve({
|
|
43
|
+
width: 0,
|
|
44
|
+
height: 0
|
|
45
|
+
});
|
|
46
|
+
img.src = url;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=pastedImageDimensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["readImageDimensionsFromBlob","blob","fallbackUrl","bitmap","createImageBitmap","width","height","close","tryImageElementDimensions","url","Promise","resolve","Image","img","onload","w","naturalWidth","h","naturalHeight","Number","isFinite","onerror","src"],"sourceRoot":"../../../src","sources":["web/pastedImageDimensions.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAEA,OAAO,eAAeA,2BAA2BA,CAC/CC,IAAU,EACVC,WAAmB,EACyB;EAC5C,IAAI;IACF,MAAMC,MAAM,GAAG,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/;
|
|
4
|
+
const WWW_REGEX = /www\.[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)/;
|
|
5
|
+
const BARE_REGEX = /[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)/;
|
|
6
|
+
const DEFAULT_AUTOLINK_SUBSTRING_PATTERN = `(?:${FULL_URL_REGEX.source})|(?:${WWW_REGEX.source})|(?:${BARE_REGEX.source})`;
|
|
7
|
+
function asGlobalRegex(re) {
|
|
8
|
+
return re.global ? re : new RegExp(re.source, `${re.flags.replace(/g/g, '')}g`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// URL-like substrings inside a single whitespace-delimited token (`\S+`),
|
|
12
|
+
export function findAutolinkRangesInWord(word, linkRegex) {
|
|
13
|
+
const re = linkRegex ? asGlobalRegex(linkRegex) : new RegExp(DEFAULT_AUTOLINK_SUBSTRING_PATTERN, 'gi');
|
|
14
|
+
const out = [];
|
|
15
|
+
for (const m of word.matchAll(re)) {
|
|
16
|
+
const text = m[0] ?? '';
|
|
17
|
+
if (text.length === 0 || m.index === undefined) continue;
|
|
18
|
+
const start = m.index;
|
|
19
|
+
out.push({
|
|
20
|
+
start,
|
|
21
|
+
endExclusive: start + text.length,
|
|
22
|
+
text
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=autolinkRegex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FULL_URL_REGEX","WWW_REGEX","BARE_REGEX","DEFAULT_AUTOLINK_SUBSTRING_PATTERN","source","asGlobalRegex","re","global","RegExp","flags","replace","findAutolinkRangesInWord","word","linkRegex","out","m","matchAll","text","length","index","undefined","start","push","endExclusive"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/AutolinkPlugin/autolinkRegex.ts"],"mappings":";;AAAA,MAAMA,cAAc,GAClB,6FAA6F;AAC/F,MAAMC,SAAS,GACb,6EAA6E;AAC/E,MAAMC,UAAU,GACd,wEAAwE;AAE1E,MAAMC,kCAAkC,GAAG,MAAMH,cAAc,CAACI,MAAM,QAAQH,SAAS,CAACG,MAAM,QAAQF,UAAU,CAACE,MAAM,GAAG;AAQ1H,SAASC,aAAaA,CAACC,EAAU,EAAU;EACzC,OAAOA,EAAE,CAACC,MAAM,GACZD,EAAE,GACF,IAAIE,MAAM,CAACF,EAAE,CAACF,MAAM,EAAE,GAAGE,EAAE,CAACG,KAAK,CAACC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC;AAC7D;;AAEA;AACA,OAAO,SAASC,wBAAwBA,CACtCC,IAAY,EACZC,SAA6B,EACG;EAChC,MAAMP,EAAE,GAAGO,SAAS,GAChBR,aAAa,CAACQ,SAAS,CAAC,GACxB,IAAIL,MAAM,CAACL,kCAAkC,EAAE,IAAI,CAAC;EAExD,MAAMW,GAA0B,GAAG,EAAE;EACrC,KAAK,MAAMC,CAAC,IAAIH,IAAI,CAACI,QAAQ,CAACV,EAAE,CAAC,EAAE;IACjC,MAAMW,IAAI,GAAGF,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;IACvB,IAAIE,IAAI,CAACC,MAAM,KAAK,CAAC,IAAIH,CAAC,CAACI,KAAK,KAAKC,SAAS,EAAE;IAChD,MAAMC,KAAK,GAAGN,CAAC,CAACI,KAAK;IACrBL,GAAG,CAACQ,IAAI,CAAC;MACPD,KAAK;MACLE,YAAY,EAAEF,KAAK,GAAGJ,IAAI,CAACC,MAAM;MACjCD;IACF,CAAC,CAAC;EACJ;EACA,OAAOH,GAAG;AACZ","ignoreList":[]}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Extension } from '@tiptap/core';
|
|
4
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
5
|
+
import { Mapping } from '@tiptap/pm/transform';
|
|
6
|
+
import { emitLinkDetected } from "../../emitLinkDetected.js";
|
|
7
|
+
import { tiptapPosToNativePos } from "../../positionMapping.js";
|
|
8
|
+
import { findAutolinkRangesInWord } from "./autolinkRegex.js";
|
|
9
|
+
const WHITESPACE_RE = /\S+/g;
|
|
10
|
+
function removeAutoLinksInRange(doc, tr, linkType, from, to) {
|
|
11
|
+
if (from >= to) return;
|
|
12
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
13
|
+
if (!node.isText) return true;
|
|
14
|
+
const link = linkType.isInSet(node.marks);
|
|
15
|
+
if (link?.attrs.auto === true) {
|
|
16
|
+
tr.removeMark(Math.max(from, pos), Math.min(to, pos + node.nodeSize), linkType);
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function rangeHasManualLink(doc, linkType, from, to) {
|
|
22
|
+
let found = false;
|
|
23
|
+
doc.nodesBetween(from, to, node => {
|
|
24
|
+
if (found) return false;
|
|
25
|
+
if (!node.isText) return true;
|
|
26
|
+
const link = linkType.isInSet(node.marks);
|
|
27
|
+
if (link && link.attrs.auto !== true) found = true;
|
|
28
|
+
return false;
|
|
29
|
+
});
|
|
30
|
+
return found;
|
|
31
|
+
}
|
|
32
|
+
function rangeHasExactAutoLink(doc, linkType, from, to, href) {
|
|
33
|
+
let hasExact = true;
|
|
34
|
+
let hasText = false;
|
|
35
|
+
doc.nodesBetween(from, to, node => {
|
|
36
|
+
if (!hasExact) return false;
|
|
37
|
+
if (!node.isText) return true;
|
|
38
|
+
hasText = true;
|
|
39
|
+
const link = linkType.isInSet(node.marks);
|
|
40
|
+
if (!link || link.attrs.auto !== true || link.attrs.href !== href) {
|
|
41
|
+
hasExact = false;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
});
|
|
45
|
+
return hasText && hasExact;
|
|
46
|
+
}
|
|
47
|
+
function extractRuns(block, blockStartPos, schema) {
|
|
48
|
+
const runs = [];
|
|
49
|
+
let current = null;
|
|
50
|
+
block.forEach((child, offset) => {
|
|
51
|
+
const eligibleText = child.isText && child.text && !schema.marks.code?.isInSet(child.marks) && !schema.marks.mention?.isInSet(child.marks);
|
|
52
|
+
if (eligibleText) {
|
|
53
|
+
if (!current) {
|
|
54
|
+
current = {
|
|
55
|
+
text: '',
|
|
56
|
+
startPos: blockStartPos + 1 + offset
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
current.text += child.text;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (current) {
|
|
63
|
+
runs.push(current);
|
|
64
|
+
current = null;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (current) runs.push(current);
|
|
68
|
+
return runs;
|
|
69
|
+
}
|
|
70
|
+
function getDirtyBlocks(doc, transactions) {
|
|
71
|
+
const mapping = new Mapping();
|
|
72
|
+
for (const tr of transactions) mapping.appendMapping(tr.mapping);
|
|
73
|
+
const blocks = new Map();
|
|
74
|
+
const docSize = doc.content.size;
|
|
75
|
+
mapping.maps.forEach((stepMap, i) => {
|
|
76
|
+
const rest = mapping.slice(i + 1);
|
|
77
|
+
stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
|
|
78
|
+
const from = Math.max(0, rest.map(newStart, -1) - 1);
|
|
79
|
+
const to = Math.min(docSize, rest.map(newEnd, 1) + 1);
|
|
80
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
81
|
+
if (node.type.name === 'codeBlock') return false;
|
|
82
|
+
if (node.inlineContent && !blocks.has(pos)) {
|
|
83
|
+
blocks.set(pos, node);
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
return Array.from(blocks, ([pos, node]) => ({
|
|
91
|
+
pos,
|
|
92
|
+
node
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
export const AutolinkPlugin = Extension.create({
|
|
96
|
+
name: 'autolinkDetector',
|
|
97
|
+
addOptions() {
|
|
98
|
+
return {
|
|
99
|
+
getLinkEmitter: () => {
|
|
100
|
+
throw new Error('AutolinkPlugin.configure({ getLinkEmitter }) is required');
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
addProseMirrorPlugins() {
|
|
105
|
+
return [new Plugin({
|
|
106
|
+
key: new PluginKey('autolinkDetector'),
|
|
107
|
+
appendTransaction: (transactions, _oldState, newState) => {
|
|
108
|
+
if (!transactions.some(tr => tr.docChanged)) return null;
|
|
109
|
+
const state = this.options.getLinkEmitter();
|
|
110
|
+
if (!state || state.linkRegex === null) return null;
|
|
111
|
+
const {
|
|
112
|
+
schema,
|
|
113
|
+
doc,
|
|
114
|
+
tr
|
|
115
|
+
} = newState;
|
|
116
|
+
const linkType = schema.marks.link;
|
|
117
|
+
if (!linkType) return null;
|
|
118
|
+
const dirtyBlocks = getDirtyBlocks(doc, transactions);
|
|
119
|
+
if (dirtyBlocks.length === 0) return null;
|
|
120
|
+
const detected = [];
|
|
121
|
+
for (const {
|
|
122
|
+
node,
|
|
123
|
+
pos
|
|
124
|
+
} of dirtyBlocks) {
|
|
125
|
+
const blockFrom = pos + 1;
|
|
126
|
+
const blockTo = pos + node.nodeSize - 1;
|
|
127
|
+
|
|
128
|
+
// find all valid links that should exist in this block
|
|
129
|
+
const desiredLinks = [];
|
|
130
|
+
for (const run of extractRuns(node, pos, schema)) {
|
|
131
|
+
for (const match of run.text.matchAll(WHITESPACE_RE)) {
|
|
132
|
+
const word = match[0];
|
|
133
|
+
const wordStart = run.startPos + match.index;
|
|
134
|
+
const wordEnd = wordStart + word.length;
|
|
135
|
+
const ranges = findAutolinkRangesInWord(word, state.linkRegex);
|
|
136
|
+
const fullMatch = ranges.some(r => r.start === 0 && r.endExclusive === word.length);
|
|
137
|
+
if (!fullMatch) continue;
|
|
138
|
+
if (rangeHasManualLink(doc, linkType, wordStart, wordEnd)) continue;
|
|
139
|
+
desiredLinks.push({
|
|
140
|
+
start: wordStart,
|
|
141
|
+
end: wordEnd,
|
|
142
|
+
href: word
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
let lastPos = blockFrom;
|
|
147
|
+
for (const link of desiredLinks) {
|
|
148
|
+
// strip auto links in the "gap" before this desired link
|
|
149
|
+
removeAutoLinksInRange(doc, tr, linkType, lastPos, link.start);
|
|
150
|
+
tr.addMark(link.start, link.end, linkType.create({
|
|
151
|
+
href: link.href,
|
|
152
|
+
auto: true
|
|
153
|
+
}));
|
|
154
|
+
const alreadyExisted = rangeHasExactAutoLink(doc, linkType, link.start, link.end, link.href);
|
|
155
|
+
|
|
156
|
+
// don't emit if the link was not changed
|
|
157
|
+
if (!alreadyExisted) {
|
|
158
|
+
detected.push({
|
|
159
|
+
text: link.href,
|
|
160
|
+
url: link.href,
|
|
161
|
+
start: tiptapPosToNativePos(doc, link.start),
|
|
162
|
+
end: tiptapPosToNativePos(doc, link.end)
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
lastPos = link.end;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// strip rest of the auto links that are now not desired
|
|
169
|
+
removeAutoLinksInRange(doc, tr, linkType, lastPos, blockTo);
|
|
170
|
+
}
|
|
171
|
+
if (tr.steps.length === 0) return null;
|
|
172
|
+
for (const event of detected) emitLinkDetected(state, event);
|
|
173
|
+
return tr;
|
|
174
|
+
}
|
|
175
|
+
})];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Extension","Plugin","PluginKey","Mapping","emitLinkDetected","tiptapPosToNativePos","findAutolinkRangesInWord","WHITESPACE_RE","removeAutoLinksInRange","doc","tr","linkType","from","to","nodesBetween","node","pos","isText","link","isInSet","marks","attrs","auto","removeMark","Math","max","min","nodeSize","rangeHasManualLink","found","rangeHasExactAutoLink","href","hasExact","hasText","extractRuns","block","blockStartPos","schema","runs","current","forEach","child","offset","eligibleText","text","code","mention","startPos","push","getDirtyBlocks","transactions","mapping","appendMapping","blocks","Map","docSize","content","size","maps","stepMap","i","rest","slice","_oldStart","_oldEnd","newStart","newEnd","map","type","name","inlineContent","has","set","Array","AutolinkPlugin","create","addOptions","getLinkEmitter","Error","addProseMirrorPlugins","key","appendTransaction","_oldState","newState","some","docChanged","state","options","linkRegex","dirtyBlocks","length","detected","blockFrom","blockTo","desiredLinks","run","match","matchAll","word","wordStart","index","wordEnd","ranges","fullMatch","r","start","endExclusive","end","lastPos","addMark","alreadyExisted","url","steps","event"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/AutolinkPlugin/index.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,cAAc;AAExC,SAASC,MAAM,EAAEC,SAAS,QAA0B,kBAAkB;AACtE,SAASC,OAAO,QAAQ,sBAAsB;AAE9C,SACEC,gBAAgB,QAEX,2BAAwB;AAC/B,SAASC,oBAAoB,QAAQ,0BAAuB;AAC5D,SAASC,wBAAwB,QAAQ,oBAAiB;AAgB1D,MAAMC,aAAa,GAAG,MAAM;AAE5B,SAASC,sBAAsBA,CAC7BC,GAAS,EACTC,EAAe,EACfC,QAAkB,EAClBC,IAAY,EACZC,EAAU,EACJ;EACN,IAAID,IAAI,IAAIC,EAAE,EAAE;EAEhBJ,GAAG,CAACK,YAAY,CAACF,IAAI,EAAEC,EAAE,EAAE,CAACE,IAAI,EAAEC,GAAG,KAAK;IACxC,IAAI,CAACD,IAAI,CAACE,MAAM,EAAE,OAAO,IAAI;IAE7B,MAAMC,IAAI,GAAGP,QAAQ,CAACQ,OAAO,CAACJ,IAAI,CAACK,KAAK,CAAC;IACzC,IAAIF,IAAI,EAAEG,KAAK,CAACC,IAAI,KAAK,IAAI,EAAE;MAC7BZ,EAAE,CAACa,UAAU,CACXC,IAAI,CAACC,GAAG,CAACb,IAAI,EAAEI,GAAG,CAAC,EACnBQ,IAAI,CAACE,G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AAI,CAACuF,KAAK,EACVvF,IAAI,CAACyF,GAAG,EACRzF,IAAI,CAACa,IACP,CAAC;;YAED;YACA,IAAI,CAAC+E,cAAc,EAAE;cACnBnB,QAAQ,CAAC3C,IAAI,CAAC;gBACZJ,IAAI,EAAE1B,IAAI,CAACa,IAAI;gBACfgF,GAAG,EAAE7F,IAAI,CAACa,IAAI;gBACd0E,KAAK,EAAEpG,oBAAoB,CAACI,GAAG,EAAES,IAAI,CAACuF,KAAK,CAAC;gBAC5CE,GAAG,EAAEtG,oBAAoB,CAACI,GAAG,EAAES,IAAI,CAACyF,GAAG;cACzC,CAAC,CAAC;YACJ;YAEAC,OAAO,GAAG1F,IAAI,CAACyF,GAAG;UACpB;;UAEA;UACAnG,sBAAsB,CAACC,GAAG,EAAEC,EAAE,EAAEC,QAAQ,EAAEiG,OAAO,EAAEf,OAAO,CAAC;QAC7D;QAEA,IAAInF,EAAE,CAACsG,KAAK,CAACtB,MAAM,KAAK,CAAC,EAAE,OAAO,IAAI;QAEtC,KAAK,MAAMuB,KAAK,IAAItB,QAAQ,EAAEvF,gBAAgB,CAACkF,KAAK,EAAE2B,KAAK,CAAC;QAC5D,OAAOvG,EAAE;MACX;IACF,CAAC,CAAC,CACH;EACH;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Extension } from '@tiptap/core';
|
|
4
|
+
import { Slice } from '@tiptap/pm/model';
|
|
5
|
+
import { Plugin } from '@tiptap/pm/state';
|
|
6
|
+
import { makeMentionPluginState } from "./makeMentionPluginState.js";
|
|
7
|
+
import { mentionPluginKey } from "./mentionPluginKey.js";
|
|
8
|
+
import { removeMentionMarksIfSpansResized } from "./removeMentionMarksIfSpansResized.js";
|
|
9
|
+
import { stripPartialMentionMarks } from "./stripPartialMentionMarks.js";
|
|
10
|
+
export { mentionPluginKey } from "./mentionPluginKey.js";
|
|
11
|
+
export { setMention } from "./setMention.js";
|
|
12
|
+
export { startMention } from "./startMention.js";
|
|
13
|
+
export { useMentionEvents } from "./useMentionEvents.js";
|
|
14
|
+
export const MentionPlugin = Extension.create({
|
|
15
|
+
name: 'mentionTrigger',
|
|
16
|
+
addOptions() {
|
|
17
|
+
return {
|
|
18
|
+
getIndicators: () => {
|
|
19
|
+
throw new Error('MentionPlugin.configure({ getIndicators }) is required');
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
addProseMirrorPlugins() {
|
|
24
|
+
return [new Plugin({
|
|
25
|
+
key: mentionPluginKey,
|
|
26
|
+
props: {
|
|
27
|
+
transformPasted(slice) {
|
|
28
|
+
return new Slice(stripPartialMentionMarks(slice.content), slice.openStart, slice.openEnd);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
state: makeMentionPluginState(this.options.getIndicators),
|
|
32
|
+
appendTransaction: removeMentionMarksIfSpansResized
|
|
33
|
+
})];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Extension","Slice","Plugin","makeMentionPluginState","mentionPluginKey","removeMentionMarksIfSpansResized","stripPartialMentionMarks","setMention","startMention","useMentionEvents","MentionPlugin","create","name","addOptions","getIndicators","Error","addProseMirrorPlugins","key","props","transformPasted","slice","content","openStart","openEnd","state","options","appendTransaction"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/index.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,sBAAsB,QAAQ,6BAA0B;AACjE,SAASC,gBAAgB,QAAQ,uBAAoB;AACrD,SAASC,gCAAgC,QAAQ,uCAAoC;AACrF,SAASC,wBAAwB,QAAQ,+BAA4B;AAIrE,SAASF,gBAAgB,QAAQ,uBAAoB;AACrD,SAASG,UAAU,QAAQ,iBAAc;AACzC,SAASC,YAAY,QAAQ,mBAAgB;AAC7C,SAASC,gBAAgB,QAAQ,uBAAoB;AAErD,OAAO,MAAMC,aAAa,GAAGV,SAAS,CAACW,MAAM,CAAuB;EAClEC,IAAI,EAAE,gBAAgB;EACtBC,UAAUA,CAAA,EAAG;IACX,OAAO;MACLC,aAAa,EAAEA,CAAA,KAAM;QACnB,MAAM,IAAIC,KAAK,CACb,wDACF,CAAC;MACH;IACF,CAAC;EACH,CAAC;EACDC,qBAAqBA,CAAA,EAAG;IACtB,OAAO,CACL,IAAId,MAAM,CAAe;MACvBe,GAAG,EAAEb,gBAAgB;MACrBc,KAAK,EAAE;QACLC,eAAeA,CAACC,KAAY,EAAS;UACnC,OAAO,IAAInB,KAAK,CACdK,wBAAwB,CAACc,KAAK,CAACC,OAAO,CAAC,EACvCD,KAAK,CAACE,SAAS,EACfF,KAAK,CAACG,OACR,CAAC;QACH;MACF,CAAC;MACDC,KAAK,EAAErB,sBAAsB,CAAC,IAAI,CAACsB,OAAO,CAACX,aAAa,CAAC;MACzDY,iBAAiB,EAAErB;IACrB,CAAC,CAAC,CACH;EACH;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { findParentNodeClosestToPos } from '@tiptap/core';
|
|
4
|
+
import { EXCLUDED_MARKS as EXCLUDED_MARKS_BY_MENTION } from "../../formats/EnrichedMention.js";
|
|
5
|
+
export function isCaretInBlockedContext($from, schema) {
|
|
6
|
+
for (const excludedMark of EXCLUDED_MARKS_BY_MENTION) {
|
|
7
|
+
if (schema.marks[excludedMark]?.isInSet($from.marks())) return true;
|
|
8
|
+
}
|
|
9
|
+
return findParentNodeClosestToPos($from, n => n.type.name === 'codeBlock') != null;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=isCaretInBlockedContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["findParentNodeClosestToPos","EXCLUDED_MARKS","EXCLUDED_MARKS_BY_MENTION","isCaretInBlockedContext","$from","schema","excludedMark","marks","isInSet","n","type","name"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/isCaretInBlockedContext.ts"],"mappings":";;AAAA,SAASA,0BAA0B,QAAQ,cAAc;AAEzD,SAASC,cAAc,IAAIC,yBAAyB,QAAQ,kCAA+B;AAE3F,OAAO,SAASC,uBAAuBA,CACrCC,KAAkB,EAClBC,MAAc,EACL;EACT,KAAK,MAAMC,YAAY,IAAIJ,yBAAyB,EAAE;IACpD,IAAIG,MAAM,CAACE,KAAK,CAACD,YAAY,CAAC,EAAEE,OAAO,CAACJ,KAAK,CAACG,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI;EACrE;EAEA,OACEP,0BAA0B,CAACI,KAAK,EAAGK,CAAC,IAAKA,CAAC,CAACC,IAAI,CAACC,IAAI,KAAK,WAAW,CAAC,IACrE,IAAI;AAER","ignoreList":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { isCaretInBlockedContext } from "./isCaretInBlockedContext.js";
|
|
4
|
+
export function makeMentionPluginState(getIndicators) {
|
|
5
|
+
return {
|
|
6
|
+
init() {
|
|
7
|
+
return {
|
|
8
|
+
active: false
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
apply(_tr, _prev, _old, newEditorState) {
|
|
12
|
+
const {
|
|
13
|
+
selection
|
|
14
|
+
} = newEditorState;
|
|
15
|
+
if (!selection.empty) return {
|
|
16
|
+
active: false
|
|
17
|
+
};
|
|
18
|
+
const $from = selection.$from;
|
|
19
|
+
if (isCaretInBlockedContext($from, newEditorState.schema)) return {
|
|
20
|
+
active: false
|
|
21
|
+
};
|
|
22
|
+
const blockStart = $from.start();
|
|
23
|
+
const wordEndPos = getCurrentWordEndPosition(newEditorState, $from);
|
|
24
|
+
const text = newEditorState.doc.textBetween(blockStart, wordEndPos, '\n', '\n');
|
|
25
|
+
const mentionType = newEditorState.schema.marks.mention;
|
|
26
|
+
const indicators = getIndicators();
|
|
27
|
+
const found = findLastValidMentionIndicator(text, indicators, idx => {
|
|
28
|
+
if (!mentionType) return false;
|
|
29
|
+
const $at = newEditorState.doc.resolve(blockStart + idx + 1);
|
|
30
|
+
return Boolean(mentionType.isInSet($at.marks()));
|
|
31
|
+
});
|
|
32
|
+
if (!found) return {
|
|
33
|
+
active: false
|
|
34
|
+
};
|
|
35
|
+
const query = text.slice(found.indexInText + 1);
|
|
36
|
+
|
|
37
|
+
// Native platforms end the trigger after two spaces in the query.
|
|
38
|
+
if ((query.match(/ /g) ?? []).length >= 2) return {
|
|
39
|
+
active: false
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
active: true,
|
|
43
|
+
indicator: found.indicator,
|
|
44
|
+
from: blockStart + found.indexInText,
|
|
45
|
+
to: wordEndPos,
|
|
46
|
+
query
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function findLastValidMentionIndicator(text, indicators, isIndicatorInsideFinalizedMention) {
|
|
52
|
+
for (let idx = text.length - 1; idx >= 0; idx--) {
|
|
53
|
+
const ch = text[idx];
|
|
54
|
+
if (!ch || !indicators.includes(ch)) continue;
|
|
55
|
+
const isAtStart = idx === 0;
|
|
56
|
+
const isAfterSpace = idx > 0 && text[idx - 1] === ' ';
|
|
57
|
+
if (!isAtStart && !isAfterSpace) continue;
|
|
58
|
+
|
|
59
|
+
// Stops inside a finalized mention
|
|
60
|
+
if (isIndicatorInsideFinalizedMention(idx)) return null;
|
|
61
|
+
return {
|
|
62
|
+
indexInText: idx,
|
|
63
|
+
indicator: ch
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
function getCurrentWordEndPosition(state, $from) {
|
|
69
|
+
const blockEnd = $from.end();
|
|
70
|
+
let wordEndPos = $from.pos;
|
|
71
|
+
while (wordEndPos < blockEnd) {
|
|
72
|
+
const char = state.doc.textBetween(wordEndPos, wordEndPos + 1);
|
|
73
|
+
if (/\s/.test(char)) {
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Break if advancing enters a blocked context
|
|
78
|
+
const $nextPos = state.doc.resolve(wordEndPos + 1);
|
|
79
|
+
if (isCaretInBlockedContext($nextPos, state.schema)) {
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
wordEndPos++;
|
|
83
|
+
}
|
|
84
|
+
return wordEndPos;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=makeMentionPluginState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isCaretInBlockedContext","makeMentionPluginState","getIndicators","init","active","apply","_tr","_prev","_old","newEditorState","selection","empty","$from","schema","blockStart","start","wordEndPos","getCurrentWordEndPosition","text","doc","textBetween","mentionType","marks","mention","indicators","found","findLastValidMentionIndicator","idx","$at","resolve","Boolean","isInSet","query","slice","indexInText","match","length","indicator","from","to","isIndicatorInsideFinalizedMention","ch","includes","isAtStart","isAfterSpace","state","blockEnd","end","pos","char","test","$nextPos"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/makeMentionPluginState.ts"],"mappings":";;AACA,SAASA,uBAAuB,QAAQ,8BAA2B;AAInE,OAAO,SAASC,sBAAsBA,CACpCC,aAAoD,EAC1B;EAC1B,OAAO;IACLC,IAAIA,CAAA,EAAiB;MACnB,OAAO;QAAEC,MAAM,EAAE;MAAM,CAAC;IAC1B,CAAC;IAEDC,KAAKA,CAACC,GAAG,EAAEC,KAAK,EAAEC,IAAI,EAAEC,cAAc,EAAgB;MACpD,MAAM;QAAEC;MAAU,CAAC,GAAGD,cAAc;MACpC,IAAI,CAACC,SAAS,CAACC,KAAK,EAAE,OAAO;QAAEP,MAAM,EAAE;MAAM,CAAC;MAE9C,MAAMQ,KAAK,GAAG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G,CAAC,CAAC;IAClD,IAAIhB,uBAAuB,CAACmD,QAAQ,EAAEN,KAAK,CAAChC,MAAM,CAAC,EAAE;MACnD;IACF;IAEAG,UAAU,EAAE;EACd;EAEA,OAAOA,UAAU;AACnB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PluginKey","mentionPluginKey"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/mentionPluginKey.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,kBAAkB;AAG5C,OAAO,MAAMC,gBAAgB,GAAG,IAAID,SAAS,CAAe,SAAS,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export function removeMentionMarksIfSpansResized(transactions, oldState, newState) {
|
|
4
|
+
if (!transactions.some(tr => tr.docChanged)) return null;
|
|
5
|
+
const mentionType = newState.schema.marks.mention;
|
|
6
|
+
if (!mentionType) return null;
|
|
7
|
+
const merged = mergeContiguousSameMarkRanges(collectMentionMarkRanges(oldState.doc, mentionType));
|
|
8
|
+
const tr = newState.tr;
|
|
9
|
+
let changed = false;
|
|
10
|
+
for (const {
|
|
11
|
+
from,
|
|
12
|
+
to,
|
|
13
|
+
mark
|
|
14
|
+
} of merged) {
|
|
15
|
+
const origLen = to - from;
|
|
16
|
+
let newFrom = from;
|
|
17
|
+
let newTo = to;
|
|
18
|
+
for (const t of transactions) {
|
|
19
|
+
newFrom = t.mapping.map(newFrom, 1);
|
|
20
|
+
newTo = t.mapping.map(newTo, -1);
|
|
21
|
+
}
|
|
22
|
+
if (newTo - newFrom !== origLen) {
|
|
23
|
+
tr.removeMark(newFrom, newTo, mark.type);
|
|
24
|
+
changed = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return changed ? tr : null;
|
|
28
|
+
}
|
|
29
|
+
function collectMentionMarkRanges(doc, mentionType) {
|
|
30
|
+
const ranges = [];
|
|
31
|
+
doc.descendants((node, pos) => {
|
|
32
|
+
if (!node.isText) return;
|
|
33
|
+
const m = mentionType.isInSet(node.marks);
|
|
34
|
+
if (m) ranges.push({
|
|
35
|
+
from: pos,
|
|
36
|
+
to: pos + node.nodeSize,
|
|
37
|
+
mark: m
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
return ranges;
|
|
41
|
+
}
|
|
42
|
+
function mergeContiguousSameMarkRanges(ranges) {
|
|
43
|
+
const merged = [];
|
|
44
|
+
for (const range of ranges) {
|
|
45
|
+
const prev = merged[merged.length - 1];
|
|
46
|
+
if (prev && prev.mark === range.mark && prev.to === range.from) {
|
|
47
|
+
prev.to = range.to;
|
|
48
|
+
} else {
|
|
49
|
+
merged.push({
|
|
50
|
+
...range
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return merged;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=removeMentionMarksIfSpansResized.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["removeMentionMarksIfSpansResized","transactions","oldState","newState","some","tr","docChanged","mentionType","schema","marks","mention","merged","mergeContiguousSameMarkRanges","collectMentionMarkRanges","doc","changed","from","to","mark","origLen","newFrom","newTo","t","mapping","map","removeMark","type","ranges","descendants","node","pos","isText","m","isInSet","push","nodeSize","range","prev","length"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/removeMentionMarksIfSpansResized.ts"],"mappings":";;AAKA,OAAO,SAASA,gCAAgCA,CAC9CC,YAAoC,EACpCC,QAAqB,EACrBC,QAAqB,EACD;EACpB,IAAI,CAACF,YAAY,CAACG,IAAI,CAAEC,EAAE,IAAKA,EAAE,CAACC,UAAU,CAAC,EAAE,OAAO,IAAI;EAE1D,MAAMC,WAAW,GAAGJ,QAAQ,CAACK,MAAM,CAACC,KAAK,CAACC,OAAO;EACjD,IAAI,CAACH,WAAW,EAAE,OAAO,IAAI;EAE7B,MAAMI,MAAM,GAAG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