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 @@
|
|
|
1
|
+
{"version":3,"names":["Fragment","TextSelection","nativePosToTiptapPos","tiptapPosToNativePos","applyWrappingListToSelection","editor","chain","listTypeName","itemTypeName","itemAttrs","doc","docBefore","selection","selBefore","state","nativeAnchor","anchor","nativeHead","head","clearNodes","command","tr","listType","schema","nodes","itemType","$from","$to","range","blockRange","listItems","i","startIndex","endIndex","block","parent","child","push","create","from","copy","content","length","list","replaceWith","start","end","docAfter","pmAnchor","pmHead","setSelection","between","resolve","run"],"sourceRoot":"../../../../src","sources":["web/formats/applyWrappingListToSelection.ts"],"mappings":";;AAEA,SAASA,QAAQ,QAAQ,kBAAkB;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,KAAK,GAAGN,KAAK,CAACO,MAAM,CAACC,KAAK,CAACL,CAAC,CAAC;MACnCD,SAAS,CAACO,IAAI,CACZZ,QAAQ,CAACa,MAAM,CAAC7B,SAAS,EAAET,QAAQ,CAACuC,IAAI,CAACL,KAAK,CAACM,IAAI,CAACN,KAAK,CAACO,OAAO,CAAC,CAAC,CACrE,CAAC;IACH;IAEA,IAAIX,SAAS,CAACY,MAAM,KAAK,CAAC,EAAE;MAC1B,OAAO,KAAK;IACd;IAEA,MAAMC,IAAI,GAAGrB,QAAQ,CAACgB,MAAM,CAAC,IAAI,EAAEtC,QAAQ,CAACuC,IAAI,CAACT,SAAS,CAAC,CAAC;IAC5DT,EAAE,CAACuB,WAAW,CAAChB,KAAK,CAACiB,KAAK,EAAEjB,KAAK,CAACkB,GAAG,EAAEH,IAAI,CAAC;IAE5C,MAAMI,QAAQ,GAAG1B,EAAE,CAACX,GAAG;IACvB,MAAMsC,QAAQ,GAAG9C,oBAAoB,CAAC6C,QAAQ,EAAEhC,YAAY,CAAC;IAC7D,MAAMkC,MAAM,GAAG/C,oBAAoB,CAAC6C,QAAQ,EAAE9B,UAAU,CAAC;IACzDI,EAAE,CAAC6B,YAAY,CACbjD,aAAa,CAACkD,OAAO,CACnBJ,QAAQ,CAACK,OAAO,CAACJ,QAAQ,CAAC,EAC1BD,QAAQ,CAACK,OAAO,CAACH,MAAM,CACzB,CACF,CAAC;IACD,OAAO,IAAI;EACb,CAAC,CAAC,CACDI,GAAG,CAAC,CAAC;AACV","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { HEADING_LEVELS, HEADING_TAGS } from "./EnrichedHeading.js";
|
|
4
|
+
export function isAnyParagraphFormatActive(editor) {
|
|
5
|
+
return editor.isActive('blockquote') || editor.isActive('codeBlock') || HEADING_LEVELS.some(level => editor.isActive('heading', {
|
|
6
|
+
level
|
|
7
|
+
})) || editor.isActive('orderedList') || editor.isActive('unorderedList') || editor.isActive('checkboxList');
|
|
8
|
+
}
|
|
9
|
+
export function isLinkBlocked(editor) {
|
|
10
|
+
return editor.isActive('code') || editor.isActive('codeBlock') || editor.isActive('mention') || editor.isActive('image');
|
|
11
|
+
}
|
|
12
|
+
function isMentionBlocked(editor) {
|
|
13
|
+
return editor.isActive('code') || editor.isActive('codeBlock') || editor.isActive('link') || editor.isActive('image');
|
|
14
|
+
}
|
|
15
|
+
export function isImageBlocked(editor) {
|
|
16
|
+
return editor.isActive('code') || editor.isActive('link') || editor.isActive('mention');
|
|
17
|
+
}
|
|
18
|
+
export function isFormatBlocked(tiptapName, editor, htmlStyle) {
|
|
19
|
+
if (tiptapName === 'image') {
|
|
20
|
+
return isImageBlocked(editor);
|
|
21
|
+
}
|
|
22
|
+
if (tiptapName === 'link') {
|
|
23
|
+
return isLinkBlocked(editor);
|
|
24
|
+
}
|
|
25
|
+
if (tiptapName === 'code' && editor.isActive('image')) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
if (tiptapName === 'mention') {
|
|
29
|
+
return isMentionBlocked(editor);
|
|
30
|
+
}
|
|
31
|
+
if (editor.isActive('codeBlock')) {
|
|
32
|
+
return ['bold', 'italic', 'underline', 'strike', 'code'].includes(tiptapName);
|
|
33
|
+
}
|
|
34
|
+
for (const level of HEADING_LEVELS) {
|
|
35
|
+
if (editor.isActive('heading', {
|
|
36
|
+
level
|
|
37
|
+
})) {
|
|
38
|
+
const key = HEADING_TAGS[level - 1];
|
|
39
|
+
if (tiptapName === 'bold' && htmlStyle[key].bold) return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
export function toggleParagraphFormat(isActive, deactivate, activate, chain) {
|
|
45
|
+
if (isActive()) return deactivate();
|
|
46
|
+
return activate(chain().clearNodes()).run();
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=formatRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["HEADING_LEVELS","HEADING_TAGS","isAnyParagraphFormatActive","editor","isActive","some","level","isLinkBlocked","isMentionBlocked","isImageBlocked","isFormatBlocked","tiptapName","htmlStyle","includes","key","bold","toggleParagraphFormat","deactivate","activate","chain","clearNodes","run"],"sourceRoot":"../../../../src","sources":["web/formats/formatRules.ts"],"mappings":";;AAEA,SAASA,cAAc,EAAEC,YAAY,QAAQ,sBAAmB;AAIhE,OAAO,SAASC,0BAA0BA,CAACC,MAAc,EAAW;EAClE,OACEA,MAAM,CAACC,QAAQ,CAAC,YAAY,CAAC,IAC7BD,MAAM,CAACC,QAAQ,CAAC,WAAW,CAAC,IAC5BJ,cAAc,CAACK,IAAI,CAAEC,KAAK,IAAKH,MAAM,CAACC,QAAQ,CAAC,SAAS,EAAE;IAAEE;EAAM,CAAC,CAAC,CAAC,IACrEH,MAAM,CAACC,QAAQ,CAAC,aAAa,CAAC,IAC9BD,MAAM,CAACC,QAAQ,CAAC,eAAe,CAAC,IAChCD,MAAM,CAACC,QAAQ,CAAC,cAAc,CAAC;AAEnC;AAEA,OAAO,SAASG,aAAaA,CAACJ,MAAc,EAAW;EACrD,OACEA,MAAM,CAACC,QAAQ,CAAC,MAAM,CAAC,IACvBD,MAAM,CAACC,QAAQ,CAAC,WAAW,CAAC,IAC5BD,MAAM,CAACC,QAAQ,CAAC,SAAS,CAAC,IAC1BD,MAAM,CAACC,QAAQ,CAAC,OAAO,CAAC;AAE5B;AACA,SAASI,gBAAgBA,CAACL,MAAc,EAAW;EACjD,OACEA,MAAM,CAACC,QAAQ,CAAC,MAAM,CAAC,IACvBD,MAAM,CAACC,QAAQ,CAAC,WAAW,CAAC,IAC5BD,MAAM,CAACC,QAAQ,CAAC,MAAM,CAAC,IACvBD,MAAM,CAACC,QAAQ,CAAC,OAAO,CAAC;AAE5B;AAEA,OAAO,SAASK,cAAcA,CAACN,MAAc,EAAW;EACtD,OACEA,MAAM,CAACC,QAAQ,CAAC,MAAM,CAAC,I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C,CAAC,CAACC,GAAG,CAAC,CAAC;AAC7C","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { isTextSelection } from '@tiptap/core';
|
|
4
|
+
import { lineStartBackspace } from "./wrappedBlockKeyboard.js";
|
|
5
|
+
function emptyListItemContent(itemName) {
|
|
6
|
+
return {
|
|
7
|
+
type: itemName,
|
|
8
|
+
content: [{
|
|
9
|
+
type: 'paragraph'
|
|
10
|
+
}]
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Enter: always extend the list — splitListItem fails on an empty last item (see TipTap splitListItem).
|
|
15
|
+
export function listEnter(editor, itemName) {
|
|
16
|
+
if (!editor.isActive(itemName)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (editor.chain().focus().splitListItem(itemName).scrollIntoView().run()) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
const {
|
|
23
|
+
selection
|
|
24
|
+
} = editor.state;
|
|
25
|
+
if (!selection.empty || !isTextSelection(selection)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const $from = selection.$from;
|
|
29
|
+
if ($from.parent.content.size > 0) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Flat lists only: list item is always the parent block of the paragraph (depth − 1).
|
|
34
|
+
const itemDepth = $from.depth - 1;
|
|
35
|
+
if (itemDepth < 1) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
const insertPos = $from.after(itemDepth);
|
|
39
|
+
return editor.chain().focus().insertContentAt(insertPos, emptyListItemContent(itemName)).scrollIntoView().run();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Backspace: first press at line start lifts the list item; second press (paragraph below list) joins backward.
|
|
43
|
+
export function listBackspace(editor, itemName, wrapperNames) {
|
|
44
|
+
return lineStartBackspace(editor, {
|
|
45
|
+
isActive: () => editor.isActive(itemName),
|
|
46
|
+
lift: () => editor.chain().focus().liftListItem(itemName).run(),
|
|
47
|
+
shouldJoinBefore: beforeName => beforeName != null && wrapperNames.includes(beforeName)
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=listKeyboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isTextSelection","lineStartBackspace","emptyListItemContent","itemName","type","content","listEnter","editor","isActive","chain","focus","splitListItem","scrollIntoView","run","selection","state","empty","$from","parent","size","itemDepth","depth","insertPos","after","insertContentAt","listBackspace","wrapperNames","lift","liftListItem","shouldJoinBefore","beforeName","includes"],"sourceRoot":"../../../../src","sources":["web/formats/listKeyboard.ts"],"mappings":";;AAAA,SAASA,eAAe,QAAuC,cAAc;AAE7E,SAASC,kBAAkB,QAAQ,2BAAwB;AAE3D,SAASC,oBAAoBA,CAACC,QAAgB,EAAe;EAC3D,OAAO;IACLC,IAAI,EAAED,QAAQ;IACdE,OAAO,EAAE,CAAC;MAAED,IAAI,EAAE;IAAY,CAAC;EACjC,CAAC;AACH;;AAEA;AACA,OAAO,SAASE,SAASA,CAACC,MAAc,EAAEJ,QAAgB,EAAW;EACnE,IAAI,CAACI,MAAM,CAACC,QAAQ,CAACL,QAAQ,CAAC,EAAE;IAC9B,OAAO,KAAK;EACd;EACA,IAAII,MAAM,CAACE,KAAK,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,CAACC,aAAa,CAACR,QAAQ,CAAC,CAACS,cAAc,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,EAAE;IACzE,OAAO,IAAI;EACb;EAEA,MAAM;IAAEC;EAAU,CAAC,GAAGP,MAAM,CAACQ,KAAK;EAClC,IAAI,CAACD,SAAS,CAACE,KAAK,IAAI,CAAChB,eAAe,CAACc,SAAS,CAAC,EAAE;IACnD,OAAO,KAAK;EACd;EAEA,MAAMG,KAAK,GAAGH,SAAS,CAACG,KAAK;EAC7B,IAAIA,KAAK,CAACC,MAAM,CAACb,OAAO,CAACc,IAAI,GAAG,CAAC,EAAE;IACjC,OAAO,KAAK;EACd;;EAEA;EACA,MAAMC,SAAS,GAAGH,KAAK,CAACI,KAAK,GAAG,CAAC;EACjC,IAAID,SAAS,GAAG,CAAC,EAAE;IACjB,OAAO,KAAK;EACd;EACA,MAAME,SAAS,GAAGL,KAAK,CAACM,KAAK,CAACH,SAAS,CAAC;EAExC,OAAOb,MAAM,CACVE,KAAK,CAAC,CAAC,CACPC,KAAK,CAAC,CAAC,CACPc,eAAe,CAACF,SAAS,EAAEpB,oBAAoB,CAACC,QAAQ,CAAC,CAAC,CAC1DS,cAAc,CAAC,CAAC,CAChBC,GAAG,CAAC,CAAC;AACV;;AAEA;AACA,OAAO,SAASY,aAAaA,CAC3BlB,MAAc,EACdJ,QAAgB,EAChBuB,YAA+B,EACtB;EACT,OAAOzB,kBAAkB,CAACM,MAAM,EAAE;IAChCC,QAAQ,EAAEA,CAAA,KAAMD,MAAM,CAACC,QAAQ,CAACL,QAAQ,CAAC;IACzCwB,IAAI,EAAEA,CAAA,KAAMpB,MAAM,CAACE,KAAK,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,CAACkB,YAAY,CAACzB,QAAQ,CAAC,CAACU,GAAG,CAAC,CAAC;IAC/DgB,gBAAgB,EAAGC,UAAU,IAC3BA,UAAU,IAAI,IAAI,IAAIJ,YAAY,CAACK,QAAQ,CAACD,UAAU;EAC1D,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { isTextSelection } from '@tiptap/core';
|
|
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) {
|
|
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(editor, options) {
|
|
22
|
+
const {
|
|
23
|
+
selection
|
|
24
|
+
} = editor.state;
|
|
25
|
+
if (!isTextSelection(selection) || !selection.$cursor || selection.$cursor.parentOffset !== 0) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (options.isActive()) {
|
|
29
|
+
return options.lift();
|
|
30
|
+
}
|
|
31
|
+
const $cut = findCutBefore(selection.$cursor);
|
|
32
|
+
const beforeName = $cut?.nodeBefore?.type.name;
|
|
33
|
+
if (options.shouldJoinBefore(beforeName)) {
|
|
34
|
+
return editor.chain().focus().joinTextblockBackward().run();
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Enter only splits inside the wrapper so the default handler does not exit the block.
|
|
40
|
+
export function wrappedBlockEnter(editor, wrapperNodeName) {
|
|
41
|
+
if (editor.isActive(wrapperNodeName)) {
|
|
42
|
+
return editor.commands.splitBlock();
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Backspace at line start inside the wrapper lifts the current paragraph out.
|
|
48
|
+
// Backspace at line start in a paragraph below the wrapper uses `joinTextblockBackward`
|
|
49
|
+
// so default `joinBackward` / `deleteBarrier` does not re-wrap the paragraph into the
|
|
50
|
+
// wrapper above.
|
|
51
|
+
export function wrappedBlockBackspace(editor, wrapperNodeName) {
|
|
52
|
+
return lineStartBackspace(editor, {
|
|
53
|
+
isActive: () => editor.isActive(wrapperNodeName),
|
|
54
|
+
lift: () => editor.chain().focus().lift(wrapperNodeName).run(),
|
|
55
|
+
shouldJoinBefore: beforeName => beforeName === wrapperNodeName
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=wrappedBlockKeyboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isTextSelection","findCutBefore","$pos","parent","type","spec","isolating","i","depth","index","doc","resolve","before","node","lineStartBackspace","editor","options","selection","state","$cursor","parentOffset","isActive","lift","$cut","beforeName","nodeBefore","name","shouldJoinBefore","chain","focus","joinTextblockBackward","run","wrappedBlockEnter","wrapperNodeName","commands","splitBlock","wrappedBlockBackspace"],"sourceRoot":"../../../../src","sources":["web/formats/wrappedBlockKeyboard.ts"],"mappings":";;AAAA,SAASA,eAAe,QAAqB,cAAc;AAG3D;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,IAAiB,EAAsB;EACnE,IAAI,CAACA,IAAI,CAACC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,EAAE;IACpC,KAAK,IAAIC,CAAC,GAAGL,IAAI,CAACM,KAAK,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;MACxC,IAAIL,IAAI,CAACO,KAAK,CAACF,CAAC,CAAC,GAAG,CAAC,EAAE;QACrB,OAAOL,IAAI,CAACQ,GAAG,CAACC,OAAO,CAACT,IAAI,CAACU,MAAM,CAACL,CAAC,GAAG,CAAC,CAAC,CAAC;MAC7C;MACA,IAAIL,IAAI,CAACW,IAAI,CAACN,CAAC,CAAC,CAACH,IAAI,CAACC,IAAI,CAACC,SAAS,EAAE;QACpC;MACF;IACF;EACF;EACA,OAAO,IAAI;AACb;;AAEA;AACA,OAAO,SAASQ,kBAAkBA,CAChCC,MAAc,EACdC,OAIC,EACQ;EACT,MAAM;IAAEC;EAAU,CAAC,GAAGF,MAAM,CAACG,KAAK;EAElC,IACE,CAAClB,eAAe,CAACiB,SAAS,CAAC,IAC3B,CAACA,SAA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
|
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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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,MAAMC,iBAAiB,CAACH,IAAI,CAAC;IAC5C,MAAM;MAAEI,KAAK;MAAEC;IAAO,CAAC,GAAGH,MAAM;IAChCA,MAAM,CAACI,KAAK,CAAC,CAAC;IACd,OAAO;MAAEF,KAAK;MAAEC;IAAO,CAAC;EAC1B,CAAC,CAAC,MAAM;IACN,OAAOE,yBAAyB,CAACN,WAAW,CAAC;EAC/C;AACF;AAEA,SAASM,yBAAyBA,CAChCC,GAAW,EACiC;EAC5C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,IAAI,OAAOC,KAAK,KAAK,WAAW,EAAE;MAChCD,OAAO,CAAC;QAAEN,KAAK,EAAE,CAAC;QAAEC,MAAM,EAAE;MAAE,CAAC,CAAC;MAChC;IACF;IACA,MAAMO,GAAG,GAAG,IAAID,KAAK,CAAC,CAAC;IACvBC,GAAG,CAACC,MAAM,GAAG,MAAM;MACjB,MAAMC,CAAC,GAAGF,GAAG,CAACG,YAAY;MAC1B,MAAMC,CAAC,GAAGJ,GAAG,CAACK,aAAa;MAC3BP,OAAO,CAAC;QACNN,KAAK,EAAEc,MAAM,CAACC,QAAQ,CAACL,CAAC,CAAC,GAAGA,CAAC,GAAG,CAAC;QACjCT,MAAM,EAAEa,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,GAAGA,CAAC,GAAG;MACnC,CAAC,CAAC;IACJ,CAAC;IACDJ,GAAG,CAACQ,OAAO,GAAG,MAAMV,OAAO,CAAC;MAAEN,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC,CAAC;IACpDO,GAAG,CAACS,GAAG,GAAGb,GAAG;EACf,CAAC,CAAC;AACJ","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 { subscribeMentionEvents } from "./subscribeMentionEvents.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","subscribeMentionEvents","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,sBAAsB,QAAQ,6BAA0B;AAEjE,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,67 @@
|
|
|
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 text = newEditorState.doc.textBetween(blockStart, $from.pos, '\n', '\n');
|
|
24
|
+
const mentionType = newEditorState.schema.marks.mention;
|
|
25
|
+
const indicators = getIndicators();
|
|
26
|
+
const found = findLastValidMentionIndicator(text, indicators, idx => {
|
|
27
|
+
if (!mentionType) return false;
|
|
28
|
+
const $at = newEditorState.doc.resolve(blockStart + idx + 1);
|
|
29
|
+
return Boolean(mentionType.isInSet($at.marks()));
|
|
30
|
+
});
|
|
31
|
+
if (!found) return {
|
|
32
|
+
active: false
|
|
33
|
+
};
|
|
34
|
+
const query = text.slice(found.indexInText + 1);
|
|
35
|
+
|
|
36
|
+
// Native platforms end the trigger after two spaces in the query.
|
|
37
|
+
if ((query.match(/ /g) ?? []).length >= 2) return {
|
|
38
|
+
active: false
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
active: true,
|
|
42
|
+
indicator: found.indicator,
|
|
43
|
+
from: blockStart + found.indexInText,
|
|
44
|
+
to: $from.pos,
|
|
45
|
+
query
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function findLastValidMentionIndicator(text, indicators, isIndicatorInsideFinalizedMention) {
|
|
51
|
+
for (let idx = text.length - 1; idx >= 0; idx--) {
|
|
52
|
+
const ch = text[idx];
|
|
53
|
+
if (!ch || !indicators.includes(ch)) continue;
|
|
54
|
+
const isAtStart = idx === 0;
|
|
55
|
+
const isAfterSpace = idx > 0 && text[idx - 1] === ' ';
|
|
56
|
+
if (!isAtStart && !isAfterSpace) continue;
|
|
57
|
+
|
|
58
|
+
// Skip indicators inside a finalized mention
|
|
59
|
+
if (isIndicatorInsideFinalizedMention(idx)) continue;
|
|
60
|
+
return {
|
|
61
|
+
indexInText: idx,
|
|
62
|
+
indicator: ch
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
//# 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","text","doc","textBetween","pos","mentionType","marks","mention","indicators","found","findLastValidMentionIndicator","idx","$at","resolve","Boolean","isInSet","query","slice","indexInText","match","length","indicator","from","to","isIndicatorInsideFinalizedMention","ch","includes","isAtStart","isAfterSpace"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/makeMentionPluginState.ts"],"mappings":";;AACA,SAASA,uBAAuB,QAAQ,8BAA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f,IAAI,CAACgB,KAAK,CAACR,KAAK,CAACS,WAAW,GAAG,CAAC,CAAC;;MAE/C;MACA,IAAI,CAACF,KAAK,CAACG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAEC,MAAM,IAAI,CAAC,EAAE,OAAO;QAAE/B,MAAM,EAAE;MAAM,CAAC;MAEnE,OAAO;QACLA,MAAM,EAAE,IAAI;QACZgC,SAAS,EAAEZ,KAAK,CAACY,SAAS;QAC1BC,IAAI,EAAEvB,UAAU,GAAGU,KAAK,CAACS,WAAW;QACpCK,EAAE,EAAE1B,KAAK,CAACO,GAAG;QACbY;MACF,CAAC;IACH;EACF,CAAC;AACH;AAEA,SAASN,6BAA6BA,CACpCT,IAAY,EACZO,UAA6B,EAC7BgB,iCAAmE,EAChB;EACnD,KAAK,IAAIb,GAAG,GAAGV,IAAI,CAACmB,MAAM,GAAG,CAAC,EAAET,GAAG,IAAI,CAAC,EAAEA,GAAG,EAAE,EAAE;IAC/C,MAAMc,EAAE,GAAGxB,IAAI,CAACU,GAAG,CAAC;IACpB,IAAI,CAACc,EAAE,IAAI,CAACjB,UAAU,CAACkB,QAAQ,CAACD,EAAE,CAAC,EAAE;IAErC,MAAME,SAAS,GAAGhB,GAAG,KAAK,CAAC;IAC3B,MAAMiB,YAAY,GAAGjB,GAAG,GAAG,CAAC,IAAIV,IAAI,CAACU,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG;IACrD,IAAI,CAACgB,SAAS,IAAI,CAACC,YAAY,EAAE;;IAEjC;IACA,IAAIJ,iCAAiC,CAACb,GAAG,CAAC,EAAE;IAE5C,OAAO;MAAEO,WAAW,EAAEP,GAAG;MAAEU,SAAS,EAAEI;IAAG,CAAC;EAC5C;EAEA,OAAO,IAAI;AACb","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,GAAGC,6BAA6B,CAC1CC,wBAAwB,CAACX,QAAQ,CAACY,GAAG,EAAEP,WAAW,CACpD,CAAC;EAED,MAAMF,EAAE,GAAGF,QAAQ,CAACE,EAAE;EACtB,IAAIU,OAAO,GAAG,KAAK;EAEnB,KAAK,MAAM;IAAEC,IAAI;IAAEC,EAAE;IAAEC;EAAK,CAAC,IAAIP,MAAM,EAAE;IACvC,MAAMQ,OAAO,GAAGF,EAAE,GAAGD,IAAI;IACzB,IA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IAAI,KAAKkB,KAAK,CAAClB,IAAI,IAAImB,IAAI,CAACpB,EAAE,KAAKmB,KAAK,CAACpB,IAAI,EAAE;MAC9DqB,IAAI,CAACpB,EAAE,GAAGmB,KAAK,CAACnB,EAAE;IACpB,CAAC,MAAM;MACLN,MAAM,CAACuB,IAAI,CAAC;QAAE,GAAGE;MAAM,CAAC,CAAC;IAC3B;EACF;EACA,OAAOzB,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Fragment } from '@tiptap/pm/model';
|
|
4
|
+
import { isCaretInBlockedContext } from "./isCaretInBlockedContext.js";
|
|
5
|
+
import { mentionPluginKey } from "./mentionPluginKey.js";
|
|
6
|
+
|
|
7
|
+
// Insert a mention mark at the current active trigger range.
|
|
8
|
+
export function setMention(editor, indicator, text, attributes) {
|
|
9
|
+
const {
|
|
10
|
+
state
|
|
11
|
+
} = editor;
|
|
12
|
+
const triggerState = mentionPluginKey.getState(state);
|
|
13
|
+
if (!triggerState?.active) {
|
|
14
|
+
console.warn('[EnrichedMention] setMention called but there is no active mention trigger');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const mentionType = state.schema.marks.mention;
|
|
18
|
+
if (!mentionType) return;
|
|
19
|
+
const $from = state.selection.$from;
|
|
20
|
+
if (isCaretInBlockedContext($from, state.schema)) {
|
|
21
|
+
console.warn('[EnrichedMention] setMention called but caret is inside a blocked context');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const {
|
|
25
|
+
from,
|
|
26
|
+
to
|
|
27
|
+
} = triggerState;
|
|
28
|
+
const extendedTo = Math.max(to, exclusiveEndThroughMatchingMentionTail(state, from, text));
|
|
29
|
+
const mentionMark = mentionType.create({
|
|
30
|
+
indicator,
|
|
31
|
+
text,
|
|
32
|
+
attributes: attributes ?? {}
|
|
33
|
+
});
|
|
34
|
+
const baseMarks = state.doc.resolve(from).marks().filter(m => m.type.name !== 'mention');
|
|
35
|
+
const fragment = Fragment.fromArray([state.schema.text(text, mentionMark.addToSet(baseMarks)), state.schema.text(' ', baseMarks)]);
|
|
36
|
+
editor.chain().focus().command(({
|
|
37
|
+
tr
|
|
38
|
+
}) => {
|
|
39
|
+
tr.replaceWith(from, extendedTo, fragment);
|
|
40
|
+
return true;
|
|
41
|
+
}).run();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// If the user moved the caret back into a partial match, extend `to` over the
|
|
45
|
+
// matching tail to avoid leftover characters after the inserted mention.
|
|
46
|
+
function exclusiveEndThroughMatchingMentionTail(state, from, text) {
|
|
47
|
+
const parentEnd = state.doc.resolve(from).end();
|
|
48
|
+
let scanPos = from;
|
|
49
|
+
for (const ch of text) {
|
|
50
|
+
const end = scanPos + ch.length;
|
|
51
|
+
if (end > parentEnd || state.doc.textBetween(scanPos, end, '') !== ch) {
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
scanPos = end;
|
|
55
|
+
}
|
|
56
|
+
return scanPos;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=setMention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Fragment","isCaretInBlockedContext","mentionPluginKey","setMention","editor","indicator","text","attributes","state","triggerState","getState","active","console","warn","mentionType","schema","marks","mention","$from","selection","from","to","extendedTo","Math","max","exclusiveEndThroughMatchingMentionTail","mentionMark","create","baseMarks","doc","resolve","filter","m","type","name","fragment","fromArray","addToSet","chain","focus","command","tr","replaceWith","run","parentEnd","end","scanPos","ch","length","textBetween"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/setMention.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,kBAAkB;AAG3C,SAASC,uBAAuB,QAAQ,8BAA2B;AACnE,SAASC,gBAAgB,QAAQ,uBAAoB;;AAErD;AACA,OAAO,SAASC,UAAUA,CACxBC,MAAc,EACdC,SAAiB,EACjBC,IAAY,EACZC,U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AC,CAClC,CAAC;EAEFxB,MAAM,CACHkC,KAAK,CAAC,CAAC,CACPC,KAAK,CAAC,CAAC,CACPC,OAAO,CAAC,CAAC;IAAEC;EAAG,CAAC,KAAK;IACnBA,EAAE,CAACC,WAAW,CAACtB,IAAI,EAAEE,UAAU,EAAEa,QAAQ,CAAC;IAC1C,OAAO,IAAI;EACb,CAAC,CAAC,CACDQ,GAAG,CAAC,CAAC;AACV;;AAEA;AACA;AACA,SAASlB,sCAAsCA,CAC7CjB,KAAkB,EAClBY,IAAY,EACZd,IAAY,EACJ;EACR,MAAMsC,SAAS,GAAGpC,KAAK,CAACqB,GAAG,CAACC,OAAO,CAACV,IAAI,CAAC,CAACyB,GAAG,CAAC,CAAC;EAC/C,IAAIC,OAAO,GAAG1B,IAAI;EAClB,KAAK,MAAM2B,EAAE,IAAIzC,IAAI,EAAE;IACrB,MAAMuC,GAAG,GAAGC,OAAO,GAAGC,EAAE,CAACC,MAAM;IAC/B,IAAIH,GAAG,GAAGD,SAAS,IAAIpC,KAAK,CAACqB,GAAG,CAACoB,WAAW,CAACH,OAAO,EAAED,GAAG,EAAE,EAAE,CAAC,KAAKE,EAAE,EAAE;MACrE;IACF;IACAD,OAAO,GAAGD,GAAG;EACf;EACA,OAAOC,OAAO;AAChB","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export function startMention(editor, indicator, indicators) {
|
|
4
|
+
if (!indicators.includes(indicator)) {
|
|
5
|
+
console.warn(`[EnrichedMention] startMention: "${indicator}" is not in mentionIndicators`);
|
|
6
|
+
}
|
|
7
|
+
editor.chain().focus().insertContent(indicator).run();
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=startMention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["startMention","editor","indicator","indicators","includes","console","warn","chain","focus","insertContent","run"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/startMention.ts"],"mappings":";;AAEA,OAAO,SAASA,YAAYA,CAC1BC,MAAc,EACdC,SAAiB,EACjBC,UAAoB,EACd;EACN,IAAI,CAACA,UAAU,CAACC,QAAQ,CAACF,SAAS,CAAC,EAAE;IACnCG,OAAO,CAACC,IAAI,CACV,oCAAoCJ,SAAS,+BAC/C,CAAC;EACH;EACAD,MAAM,CAACM,KAAK,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,CAACC,aAAa,CAACP,SAAS,CAAC,CAACQ,GAAG,CAAC,CAAC;AACvD","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Fragment } from '@tiptap/pm/model';
|
|
4
|
+
export function stripPartialMentionMarks(fragment) {
|
|
5
|
+
const nodes = [];
|
|
6
|
+
fragment.forEach(node => nodes.push(node.isText ? node.mark(node.marks.filter(m => m.type.name !== 'mention' || node.text === m.attrs.text)) : node.copy(stripPartialMentionMarks(node.content))));
|
|
7
|
+
return Fragment.from(nodes);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=stripPartialMentionMarks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Fragment","stripPartialMentionMarks","fragment","nodes","forEach","node","push","isText","mark","marks","filter","m","type","name","text","attrs","copy","content","from"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/stripPartialMentionMarks.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,kBAAkB;AAG3C,OAAO,SAASC,wBAAwBA,CAACC,QAAkB,EAAY;EACrE,MAAMC,KAAa,GAAG,EAAE;EACxBD,QAAQ,CAACE,OAAO,CAAEC,IAAI,IACpBF,KAAK,CAACG,IAAI,CACRD,IAAI,CAACE,MAAM,GACPF,IAAI,CAACG,IAAI,CACPH,IAAI,CAACI,KAAK,CAACC,MAAM,CACdC,CAAC,IACAA,CAAC,CAACC,IAAI,CAACC,IAAI,KAAK,SAAS,IACzBR,IAAI,CAACS,IAAI,KAAMH,CAAC,CAACI,KAAK,CAACD,IAC3B,CACF,CAAC,GACDT,IAAI,CAACW,IAAI,CAACf,wBAAwB,CAACI,IAAI,CAACY,OAAO,CAAC,CACtD,CACF,CAAC;EACD,OAAOjB,QAAQ,CAACkB,IAAI,CAACf,KAAK,CAAC;AAC7B","ignoreList":[]}
|