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,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Fragment } from '@tiptap/pm/model';
|
|
4
|
+
import { TextSelection } from '@tiptap/pm/state';
|
|
5
|
+
import { isCaretInBlockedContext } from "./isCaretInBlockedContext.js";
|
|
6
|
+
import { mentionPluginKey } from "./mentionPluginKey.js";
|
|
7
|
+
|
|
8
|
+
// Insert a mention mark at the current active trigger range.
|
|
9
|
+
export function setMention(editor, indicator, text, attributes) {
|
|
10
|
+
const {
|
|
11
|
+
state
|
|
12
|
+
} = editor;
|
|
13
|
+
const triggerState = mentionPluginKey.getState(state);
|
|
14
|
+
if (!triggerState?.active) {
|
|
15
|
+
console.warn('[EnrichedMention] setMention called but there is no active mention trigger');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const mentionType = state.schema.marks.mention;
|
|
19
|
+
if (!mentionType) return;
|
|
20
|
+
const $from = state.selection.$from;
|
|
21
|
+
if (isCaretInBlockedContext($from, state.schema)) {
|
|
22
|
+
console.warn('[EnrichedMention] setMention called but caret is inside a blocked context');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const {
|
|
26
|
+
from,
|
|
27
|
+
to
|
|
28
|
+
} = triggerState;
|
|
29
|
+
|
|
30
|
+
// avoid inserting a space if there already is one
|
|
31
|
+
const parentEnd = state.doc.resolve(to).end();
|
|
32
|
+
let hasSpaceAfter = false;
|
|
33
|
+
if (to < parentEnd) {
|
|
34
|
+
const charAfter = state.doc.textBetween(to, to + 1, '');
|
|
35
|
+
hasSpaceAfter = /\s/.test(charAfter);
|
|
36
|
+
}
|
|
37
|
+
const mentionMark = mentionType.create({
|
|
38
|
+
indicator,
|
|
39
|
+
text,
|
|
40
|
+
attributes: attributes ?? {}
|
|
41
|
+
});
|
|
42
|
+
const baseMarks = state.doc.resolve(from).marks().filter(m => m.type.name !== 'mention');
|
|
43
|
+
const nodes = [state.schema.text(text, mentionMark.addToSet(baseMarks))];
|
|
44
|
+
if (!hasSpaceAfter) {
|
|
45
|
+
nodes.push(state.schema.text(' ', baseMarks));
|
|
46
|
+
}
|
|
47
|
+
const fragment = Fragment.fromArray(nodes);
|
|
48
|
+
editor.chain().focus().command(({
|
|
49
|
+
tr
|
|
50
|
+
}) => {
|
|
51
|
+
tr.replaceWith(from, to, fragment);
|
|
52
|
+
const targetPos = from + fragment.size + (hasSpaceAfter ? 1 : 0);
|
|
53
|
+
tr.setSelection(TextSelection.create(tr.doc, targetPos));
|
|
54
|
+
return true;
|
|
55
|
+
}).run();
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=setMention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Fragment","TextSelection","isCaretInBlockedContext","mentionPluginKey","setMention","editor","indicator","text","attributes","state","triggerState","getState","active","console","warn","mentionType","schema","marks","mention","$from","selection","from","to","parentEnd","doc","resolve","end","hasSpaceAfter","charAfter","textBetween","test","mentionMark","create","baseMarks","filter","m","type","name","nodes","addToSet","push","fragment","fromArray","chain","focus","command","tr","replaceWith","targetPos","size","setSelection","run"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/setMention.ts"],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,EAAEA,UAAU,IAAI,CAAC;EAC7B,CAAC,CAAC;EACF,MAAMyB,SAAS,GAAGxB,KAAK,CAACe,GAAG,CACxBC,OAAO,CAACJ,IAAI,CAAC,CACbJ,KAAK,CAAC,CAAC,CACPiB,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,CAACC,IAAI,KAAK,SAAS,CAAC;EAE3C,MAAMC,KAAK,GAAG,CAAC7B,KAAK,CAACO,MAAM,CAACT,IAAI,CAACA,IAAI,EAAEwB,WAAW,CAACQ,QAAQ,CAACN,SAAS,CAAC,CAAC,CAAC;EACxE,IAAI,CAACN,aAAa,EAAE;IAClBW,KAAK,CAACE,IAAI,CAAC/B,KAAK,CAACO,MAAM,CAACT,IAAI,CAAC,GAAG,EAAE0B,SAAS,CAAC,CAAC;EAC/C;EACA,MAAMQ,QAAQ,GAAGzC,QAAQ,CAAC0C,SAAS,CAACJ,KAAK,CAAC;EAE1CjC,MAAM,CACHsC,KAAK,CAAC,CAAC,CACPC,KAAK,CAAC,CAAC,CACPC,OAAO,CAAC,CAAC;IAAEC;EAAG,CAAC,KAAK;IACnBA,EAAE,CAACC,WAAW,CAAC1B,IAAI,EAAEC,EAAE,EAAEmB,QAAQ,CAAC;IAElC,MAAMO,SAAS,GAAG3B,IAAI,GAAGoB,QAAQ,CAACQ,IAAI,IAAItB,aAAa,GAAG,CAAC,GAAG,CAAC,CAAC;IAChEmB,EAAE,CAACI,YAAY,CAACjD,aAAa,CAAC+B,MAAM,CAACc,EAAE,CAACtB,GAAG,EAAEwB,SAAS,CAAC,CAAC;IAExD,OAAO,IAAI;EACb,CAAC,CAAC,CACDG,GAAG,CAAC,CAAC;AACV","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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { getMarkRange } from '@tiptap/core';
|
|
4
|
+
import { mentionPluginKey } from "./mentionPluginKey.js";
|
|
5
|
+
import { useEffect } from 'react';
|
|
6
|
+
export function useMentionEvents(editor, getCallbacks) {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
let prevTriggerState = {
|
|
9
|
+
active: false
|
|
10
|
+
};
|
|
11
|
+
let prevMentionKey = null;
|
|
12
|
+
let wasInMention = false;
|
|
13
|
+
const handleUpdate = () => {
|
|
14
|
+
const cb = getCallbacks();
|
|
15
|
+
const curr = mentionPluginKey.getState(editor.state);
|
|
16
|
+
if (!curr) return;
|
|
17
|
+
if (!prevTriggerState.active && curr.active) {
|
|
18
|
+
cb.onStartMention?.(curr.indicator);
|
|
19
|
+
if (curr.query !== '') cb.onChangeMention?.({
|
|
20
|
+
indicator: curr.indicator,
|
|
21
|
+
text: curr.query
|
|
22
|
+
});
|
|
23
|
+
} else if (prevTriggerState.active && curr.active && prevTriggerState.indicator !== curr.indicator) {
|
|
24
|
+
cb.onEndMention?.(prevTriggerState.indicator);
|
|
25
|
+
cb.onStartMention?.(curr.indicator);
|
|
26
|
+
if (curr.query !== '') cb.onChangeMention?.({
|
|
27
|
+
indicator: curr.indicator,
|
|
28
|
+
text: curr.query
|
|
29
|
+
});
|
|
30
|
+
} else if (prevTriggerState.active && curr.active && curr.query !== prevTriggerState.query) {
|
|
31
|
+
cb.onChangeMention?.({
|
|
32
|
+
indicator: curr.indicator,
|
|
33
|
+
text: curr.query
|
|
34
|
+
});
|
|
35
|
+
} else if (prevTriggerState.active && !curr.active) {
|
|
36
|
+
cb.onEndMention?.(prevTriggerState.indicator);
|
|
37
|
+
}
|
|
38
|
+
prevTriggerState = curr;
|
|
39
|
+
if (!cb.onMentionDetected) return;
|
|
40
|
+
const mention = getMentionInCurrentSelection(editor.state);
|
|
41
|
+
if (!mention) {
|
|
42
|
+
if (wasInMention) {
|
|
43
|
+
cb.onMentionDetected({
|
|
44
|
+
text: '',
|
|
45
|
+
indicator: '',
|
|
46
|
+
attributes: {}
|
|
47
|
+
});
|
|
48
|
+
wasInMention = false;
|
|
49
|
+
prevMentionKey = null;
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
wasInMention = true;
|
|
53
|
+
if (mention.key === prevMentionKey) return;
|
|
54
|
+
prevMentionKey = mention.key;
|
|
55
|
+
cb.onMentionDetected({
|
|
56
|
+
text: mention.text,
|
|
57
|
+
indicator: mention.indicator,
|
|
58
|
+
attributes: mention.attributes
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const handleBlur = () => {
|
|
63
|
+
const cb = getCallbacks();
|
|
64
|
+
if (prevTriggerState.active) {
|
|
65
|
+
cb.onEndMention?.(prevTriggerState.indicator);
|
|
66
|
+
prevTriggerState = {
|
|
67
|
+
active: false
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
prevMentionKey = null;
|
|
71
|
+
};
|
|
72
|
+
editor.on('transaction', handleUpdate);
|
|
73
|
+
editor.on('blur', handleBlur);
|
|
74
|
+
return () => {
|
|
75
|
+
editor.off('transaction', handleUpdate);
|
|
76
|
+
editor.off('blur', handleBlur);
|
|
77
|
+
};
|
|
78
|
+
}, [editor, getCallbacks]);
|
|
79
|
+
}
|
|
80
|
+
function getMentionInCurrentSelection(state) {
|
|
81
|
+
const mentionType = state.schema.marks.mention;
|
|
82
|
+
if (!mentionType) return null;
|
|
83
|
+
const {
|
|
84
|
+
from: selFrom,
|
|
85
|
+
to: selTo
|
|
86
|
+
} = state.selection;
|
|
87
|
+
const $from = state.doc.resolve(selFrom);
|
|
88
|
+
const mark = mentionType.isInSet($from.marks());
|
|
89
|
+
if (!mark) return null;
|
|
90
|
+
const range = getMarkRange($from, mentionType);
|
|
91
|
+
if (!range) return null;
|
|
92
|
+
if (selFrom < range.from || selTo > range.to) return null;
|
|
93
|
+
const {
|
|
94
|
+
text,
|
|
95
|
+
indicator,
|
|
96
|
+
attributes
|
|
97
|
+
} = mark.attrs;
|
|
98
|
+
return {
|
|
99
|
+
key: `${range.from}:${range.to}:${text}:${indicator}`,
|
|
100
|
+
text: text,
|
|
101
|
+
indicator: indicator,
|
|
102
|
+
attributes: attributes ?? {}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=useMentionEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getMarkRange","mentionPluginKey","useEffect","useMentionEvents","editor","getCallbacks","prevTriggerState","active","prevMentionKey","wasInMention","handleUpdate","cb","curr","getState","state","onStartMention","indicator","query","onChangeMention","text","onEndMention","onMentionDetected","mention","getMentionInCurrentSelection","attributes","key","handleBlur","on","off","mentionType","schema","marks","from","selFrom","to","selTo","selection","$from","doc","resolve","mark","isInSet","range","attrs"],"sourceRoot":"../../../../../src","sources":["web/pmPlugins/MentionPlugin/useMentionEvents.ts"],"mappings":";;AAAA,SAASA,YA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IAAI,IAAIU,KAAK,CAACR,EAAE,IAAIf,IAAI,IAAIH,SAAS,EAAE;IACrDG,IAAI,EAAEA,IAAc;IACpBH,SAAS,EAAEA,SAAmB;IAC9BQ,UAAU,EAAGA,UAAU,IAAI,CAAC;EAC9B,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Extension } from '@tiptap/core';
|
|
4
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
5
|
+
import { canJoin } from '@tiptap/pm/transform';
|
|
6
|
+
const MERGEABLE_TYPE_NAMES = new Set(['blockquote', 'codeBlock', 'unorderedList', 'orderedList', 'checkboxList']);
|
|
7
|
+
export const MergeAdjacentSameKindBlocksPlugin = Extension.create({
|
|
8
|
+
name: 'mergeAdjacentSameKindBlocks',
|
|
9
|
+
addProseMirrorPlugins() {
|
|
10
|
+
return [new Plugin({
|
|
11
|
+
key: new PluginKey('mergeAdjacentSameKindBlocks'),
|
|
12
|
+
appendTransaction: (transactions, _oldState, newState) => {
|
|
13
|
+
if (!transactions.some(t => t.docChanged)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const tr = newState.tr;
|
|
17
|
+
const joinPositions = [];
|
|
18
|
+
newState.doc.descendants((node, pos) => {
|
|
19
|
+
if (!MERGEABLE_TYPE_NAMES.has(node.type.name)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
const boundaryPos = pos + node.nodeSize;
|
|
23
|
+
const $pos = newState.doc.resolve(boundaryPos);
|
|
24
|
+
const after = $pos.nodeAfter;
|
|
25
|
+
if (after && after.type === node.type) {
|
|
26
|
+
joinPositions.push(boundaryPos);
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
});
|
|
30
|
+
let hasMerged = false;
|
|
31
|
+
joinPositions.sort((a, b) => b - a).forEach(pos => {
|
|
32
|
+
if (canJoin(tr.doc, pos)) {
|
|
33
|
+
tr.join(pos);
|
|
34
|
+
hasMerged = true;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return hasMerged ? tr : undefined;
|
|
38
|
+
}
|
|
39
|
+
})];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=MergeAdjacentSameKindBlocksPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Extension","Plugin","PluginKey","canJoin","MERGEABLE_TYPE_NAMES","Set","MergeAdjacentSameKindBlocksPlugin","create","name","addProseMirrorPlugins","key","appendTransaction","transactions","_oldState","newState","some","t","docChanged","tr","joinPositions","doc","descendants","node","pos","has","type","boundaryPos","nodeSize","$pos","resolve","after","nodeAfter","push","hasMerged","sort","a","b","forEach","join","undefined"],"sourceRoot":"../../../../src","sources":["web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,MAAM,EAAEC,SAAS,QAAQ,kBAAkB;AACpD,SAASC,OAAO,QAAQ,sBAAsB;AAE9C,MAAMC,oBAAoB,GAAG,IAAIC,GAAG,CAAC,CACnC,YAAY,EACZ,WAAW,EACX,eAAe,EACf,aAAa,EACb,cAAc,CACf,CAAC;AAEF,OAAO,MAAMC,iCAAiC,GAAGN,SAAS,CAACO,MAAM,CAAC;EAChEC,IAAI,EAAE,6BAA6B;EAEnCC,qBAAqBA,CAAA,EAAG;IACtB,OAAO,CACL,IAAIR,MAAM,CAAC;MACTS,GAAG,EAAE,IAAIR,SAAS,CAAC,6BAA6B,CAAC;MACjDS,iBAAiB,EAAEA,CAACC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,KAAK;QACxD,IAAI,CAACF,YAAY,CAACG,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,UAAU,CAAC,EAAE;UAC3C;QACF;QAEA,MAAMC,EAAE,GAAGJ,QAAQ,CAACI,EAAE;QACtB,MAAMC,aAAuB,GAAG,EAAE;QAElCL,QAAQ,CAACM,GAAG,CAACC,WAAW,CAAC,CAACC,IAAI,EAAEC,GAAG,KAAK;UACtC,IAAI,CAACnB,oBAAoB,CAACoB,GAAG,CAACF,IAAI,CAACG,IAAI,CAACjB,IAAI,CAAC,EAAE;YAC7C,OAAO,IAAI;UACb;UAEA,MAAMkB,WAAW,GAAGH,GAAG,GAAGD,IAAI,CAACK,QAAQ;UACvC,MAAMC,IAAI,GAAGd,QAAQ,CAACM,GAAG,CAACS,OAAO,CAACH,WAAW,CAAC;UAC9C,MAAMI,KAAK,GAAGF,IAAI,CAACG,SAAS;UAC5B,IAAID,KAAK,IAAIA,KAAK,CAACL,IAAI,KAAKH,IAAI,CAACG,IAAI,EAAE;YACrCN,aAAa,CAACa,IAAI,CAACN,WAAW,CAAC;UACjC;UACA,OAAO,IAAI;QACb,CAAC,CAAC;QAEF,IAAIO,SAAS,GAAG,KAAK;QACrBd,aAAa,CACVe,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKA,CAAC,GAAGD,CAAC,CAAC,CACrBE,OAAO,CAAEd,GAAG,IAAK;UAChB,IAAIpB,OAAO,CAACe,EAAE,CAACE,GAAG,EAAEG,GAAG,CAAC,EAAE;YACxBL,EAAE,CAACoB,IAAI,CAACf,GAAG,CAAC;YACZU,SAAS,GAAG,IAAI;UAClB;QACF,CAAC,CAAC;QAEJ,OAAOA,SAAS,GAAGf,EAAE,GAAGqB,SAAS;MACnC;IACF,CAAC,CAAC,CACH;EACH;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Extension } from '@tiptap/core';
|
|
4
|
+
import { isFormatBlocked } from "../formats/formatRules.js";
|
|
5
|
+
function insertPlainTextFromClipboard(editor) {
|
|
6
|
+
return navigator.clipboard.readText().then(text => {
|
|
7
|
+
if (editor.isDestroyed) return;
|
|
8
|
+
editor.chain().focus().deleteSelection().insertContent(text).run();
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export const ShortcutPlugin = Extension.create({
|
|
12
|
+
name: 'shortcutPlugin',
|
|
13
|
+
addOptions() {
|
|
14
|
+
return {
|
|
15
|
+
getHtmlStyle: () => {
|
|
16
|
+
throw new Error('ShortcutPlugin.configure({ getHtmlStyle }) is required');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
addKeyboardShortcuts() {
|
|
21
|
+
const htmlStyle = () => this.options.getHtmlStyle();
|
|
22
|
+
const mark = (name, run) => ({
|
|
23
|
+
editor
|
|
24
|
+
}) => {
|
|
25
|
+
if (!editor.isEditable) return false;
|
|
26
|
+
if (isFormatBlocked(name, editor, htmlStyle())) return true;
|
|
27
|
+
return run(editor);
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
'Mod-a': ({
|
|
31
|
+
editor
|
|
32
|
+
}) => {
|
|
33
|
+
const {
|
|
34
|
+
doc
|
|
35
|
+
} = editor.state;
|
|
36
|
+
return editor.commands.setTextSelection({
|
|
37
|
+
from: 0,
|
|
38
|
+
to: doc.content.size
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
'Mod-Shift-v': ({
|
|
42
|
+
editor
|
|
43
|
+
}) => {
|
|
44
|
+
if (!editor.isEditable) return false;
|
|
45
|
+
insertPlainTextFromClipboard(editor).catch(() => {});
|
|
46
|
+
return true;
|
|
47
|
+
},
|
|
48
|
+
'Mod-Alt-Shift-c': ({
|
|
49
|
+
editor
|
|
50
|
+
}) => {
|
|
51
|
+
if (!editor.isEditable) return false;
|
|
52
|
+
return editor.commands.toggleCodeBlock();
|
|
53
|
+
},
|
|
54
|
+
'Mod-Shift-c': mark('code', editor => editor.commands.toggleCode()),
|
|
55
|
+
'Mod-Shift-x': mark('strike', editor => editor.commands.toggleStrike()),
|
|
56
|
+
'Mod-b': mark('bold', editor => editor.commands.toggleBold()),
|
|
57
|
+
'Mod-i': mark('italic', editor => editor.commands.toggleItalic()),
|
|
58
|
+
'Mod-u': mark('underline', editor => editor.commands.toggleUnderline()),
|
|
59
|
+
'Mod-Shift-7': ({
|
|
60
|
+
editor
|
|
61
|
+
}) => {
|
|
62
|
+
if (!editor.isEditable) return false;
|
|
63
|
+
return editor.commands.toggleOrderedList();
|
|
64
|
+
},
|
|
65
|
+
'Mod-Shift-8': ({
|
|
66
|
+
editor
|
|
67
|
+
}) => {
|
|
68
|
+
if (!editor.isEditable) return false;
|
|
69
|
+
return editor.commands.toggleUnorderedList();
|
|
70
|
+
},
|
|
71
|
+
'Mod-Shift-9': ({
|
|
72
|
+
editor
|
|
73
|
+
}) => {
|
|
74
|
+
if (!editor.isEditable) return false;
|
|
75
|
+
return editor.commands.toggleCheckboxList(false);
|
|
76
|
+
},
|
|
77
|
+
'Mod-Alt-0': ({
|
|
78
|
+
editor
|
|
79
|
+
}) => {
|
|
80
|
+
if (!editor.isEditable) return false;
|
|
81
|
+
return editor.commands.setParagraph();
|
|
82
|
+
},
|
|
83
|
+
'Mod-Alt-1': ({
|
|
84
|
+
editor
|
|
85
|
+
}) => {
|
|
86
|
+
if (!editor.isEditable) return false;
|
|
87
|
+
return editor.commands.toggleHeading({
|
|
88
|
+
level: 1
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
'Mod-Alt-2': ({
|
|
92
|
+
editor
|
|
93
|
+
}) => {
|
|
94
|
+
if (!editor.isEditable) return false;
|
|
95
|
+
return editor.commands.toggleHeading({
|
|
96
|
+
level: 2
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
'Mod-Alt-3': ({
|
|
100
|
+
editor
|
|
101
|
+
}) => {
|
|
102
|
+
if (!editor.isEditable) return false;
|
|
103
|
+
return editor.commands.toggleHeading({
|
|
104
|
+
level: 3
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
'Mod-Alt-4': ({
|
|
108
|
+
editor
|
|
109
|
+
}) => {
|
|
110
|
+
if (!editor.isEditable) return false;
|
|
111
|
+
return editor.commands.toggleHeading({
|
|
112
|
+
level: 4
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
'Mod-Alt-5': ({
|
|
116
|
+
editor
|
|
117
|
+
}) => {
|
|
118
|
+
if (!editor.isEditable) return false;
|
|
119
|
+
return editor.commands.toggleHeading({
|
|
120
|
+
level: 5
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
'Mod-Alt-6': ({
|
|
124
|
+
editor
|
|
125
|
+
}) => {
|
|
126
|
+
if (!editor.isEditable) return false;
|
|
127
|
+
return editor.commands.toggleHeading({
|
|
128
|
+
level: 6
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
//# sourceMappingURL=ShortcutPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Extension","isFormatBlocked","insertPlainTextFromClipboard","editor","navigator","clipboard","readText","then","text","isDestroyed","chain","focus","deleteSelection","insertContent","run","ShortcutPlugin","create","name","addOptions","getHtmlStyle","Error","addKeyboardShortcuts","htmlStyle","options","mark","isEditable","Mod-a","doc","state","commands","setTextSelection","from","to","content","size","Mod-Shift-v","catch","Mod-Alt-Shift-c","toggleCodeBlock","toggleCode","toggleStrike","toggleBold","toggleItalic","toggleUnderline","Mod-Shift-7","toggleOrderedList","Mod-Shift-8","toggleUnorderedList","Mod-Shift-9","toggleCheckboxList","Mod-Alt-0","setParagraph","Mod-Alt-1","toggleHeading","level","Mod-Alt-2","Mod-Alt-3","Mod-Alt-4","Mod-Alt-5","Mod-Alt-6"],"sourceRoot":"../../../../src","sources":["web/pmPlugins/ShortcutPlugin.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAqB,cAAc;AAGrD,SAASC,eAAe,QAAQ,2BAAwB;AAMxD,SAASC,4BAA4BA,CAACC,MAAc,EAAiB;EACnE,OAAOC,SAAS,CAACC,SAAS,CAACC,QAAQ,CAAC,CAAC,CAACC,IAAI,CAAEC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MAAO,CAAC,KAAK;QAC3B,IAAI,CAACA,MAAM,CAACsB,UAAU,EAAE,OAAO,KAAK;QACpC,OAAOtB,MAAM,CAAC0B,QAAQ,CAACwB,aAAa,CAAC;UAAEC,KAAK,EAAE;QAAE,CAAC,CAAC;MACpD,CAAC;MACD,WAAW,EAAEK,CAAC;QAAExD;MAAO,CAAC,KAAK;QAC3B,IAAI,CAACA,MAAM,CAACsB,UAAU,EAAE,OAAO,KAAK;QACpC,OAAOtB,MAAM,CAAC0B,QAAQ,CAACwB,aAAa,CAAC;UAAEC,KAAK,EAAE;QAAE,CAAC,CAAC;MACpD;IACF,CAAC;EACH;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Extension } from '@tiptap/core';
|
|
4
|
+
import { Mark } from '@tiptap/pm/model';
|
|
5
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
6
|
+
const NONINCLUSIVE_MARKS = ['link', 'mention'];
|
|
7
|
+
function stripNonInclusiveMarksFromSet(schema, marks) {
|
|
8
|
+
let out = marks.slice();
|
|
9
|
+
for (const name of NONINCLUSIVE_MARKS) {
|
|
10
|
+
const markType = schema.marks[name];
|
|
11
|
+
if (!markType?.isInSet(out)) continue;
|
|
12
|
+
out = out.filter(m => m.type !== markType);
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
}
|
|
16
|
+
function stripNonInclusiveMarksIfAfterIsOut(schema, $from) {
|
|
17
|
+
const nodeBefore = $from.nodeBefore;
|
|
18
|
+
if (!nodeBefore) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
let out = nodeBefore.marks;
|
|
22
|
+
for (const name of NONINCLUSIVE_MARKS) {
|
|
23
|
+
const markType = schema.marks[name];
|
|
24
|
+
if (!markType?.isInSet(out)) continue;
|
|
25
|
+
const afterHasMark = $from.nodeAfter != null && markType.isInSet($from.nodeAfter.marks);
|
|
26
|
+
if (!afterHasMark) {
|
|
27
|
+
out = out.filter(m => m.type !== markType);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
function resolveStrictMarks($from, oldState, newState, docChanged, textLengthChanged) {
|
|
33
|
+
// Editor completely empty
|
|
34
|
+
if (newState.doc.textContent.length === 0) {
|
|
35
|
+
return textLengthChanged ? [] : oldState.storedMarks ?? newState.storedMarks ?? [];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Character to the left: strictly inherit from it
|
|
39
|
+
if ($from.nodeBefore) {
|
|
40
|
+
// Non-inclusive marks: do not carry onto text typed after the last marked
|
|
41
|
+
// character (e.g. space exits link/mention, matching native).
|
|
42
|
+
return stripNonInclusiveMarksIfAfterIsOut(newState.schema, $from);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Start of line with text to the right
|
|
46
|
+
if ($from.nodeAfter) {
|
|
47
|
+
if (!docChanged) {
|
|
48
|
+
return []; // Pure cursor movement: kill RTL mark bleeding
|
|
49
|
+
}
|
|
50
|
+
const old$ = oldState.selection.$from;
|
|
51
|
+
const {
|
|
52
|
+
nodeBefore: oldBefore,
|
|
53
|
+
nodeAfter: oldAfter
|
|
54
|
+
} = old$;
|
|
55
|
+
// Styled|plain boundary after Enter/paste/etc.: inherit the left inline's marks so
|
|
56
|
+
// bold, code, and other marks behave the same on a new paragraph.
|
|
57
|
+
if (oldBefore && oldAfter && !Mark.sameSet(oldBefore.marks, oldAfter.marks)) {
|
|
58
|
+
return stripNonInclusiveMarksFromSet(newState.schema, oldBefore.marks);
|
|
59
|
+
}
|
|
60
|
+
return stripNonInclusiveMarksFromSet(newState.schema, $from.nodeAfter.marks);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Completely empty line
|
|
64
|
+
if (textLengthChanged) {
|
|
65
|
+
const prevEndPos = $from.before() - 1;
|
|
66
|
+
return prevEndPos > 0 ? newState.doc.resolve(prevEndPos).marks() : [];
|
|
67
|
+
}
|
|
68
|
+
if (oldState.storedMarks) {
|
|
69
|
+
return oldState.storedMarks; // Structural nav (Enter/Backspace): keep explicit marks
|
|
70
|
+
}
|
|
71
|
+
return newState.storedMarks ?? $from.marks();
|
|
72
|
+
}
|
|
73
|
+
export const StrictMarksPlugin = Extension.create({
|
|
74
|
+
name: 'strictMarksPlugin',
|
|
75
|
+
addProseMirrorPlugins() {
|
|
76
|
+
return [new Plugin({
|
|
77
|
+
key: new PluginKey('strictMarks'),
|
|
78
|
+
appendTransaction(transactions, oldState, newState) {
|
|
79
|
+
const {
|
|
80
|
+
selection
|
|
81
|
+
} = newState;
|
|
82
|
+
if (!selection.empty) return null;
|
|
83
|
+
const docChanged = !oldState.doc.eq(newState.doc);
|
|
84
|
+
const selChanged = !oldState.selection.eq(newState.selection);
|
|
85
|
+
if (!docChanged && !selChanged) return null;
|
|
86
|
+
const isExplicitToggle = !docChanged && transactions.some(tr => tr.storedMarks !== null);
|
|
87
|
+
if (isExplicitToggle) return null;
|
|
88
|
+
const {
|
|
89
|
+
$from
|
|
90
|
+
} = selection;
|
|
91
|
+
const textLengthChanged = oldState.doc.textContent.length !== newState.doc.textContent.length;
|
|
92
|
+
const strictMarks = resolveStrictMarks($from, oldState, newState, docChanged, textLengthChanged);
|
|
93
|
+
const activeMarks = newState.storedMarks ?? $from.marks();
|
|
94
|
+
if (Mark.sameSet(strictMarks, activeMarks)) return null;
|
|
95
|
+
return newState.tr.setStoredMarks(strictMarks);
|
|
96
|
+
}
|
|
97
|
+
})];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=StrictMarksPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Extension","Mark","Plugin","PluginKey","NONINCLUSIVE_MARKS","stripNonInclusiveMarksFromSet","schema","marks","out","slice","name","markType","isInSet","filter","m","type","stripNonInclusiveMarksIfAfterIsOut","$from","nodeBefore","afterHasMark","nodeAfter","resolveStrictMarks","oldState","newState","docChanged","textLengthChanged","doc","textContent","length","storedMarks","old$","selection","oldBefore","oldAfter","sameSet","prevEndPos","before","resolve","StrictMarksPlugin","create","addProseMirrorPlugins","key","appendTransaction","transactions","empty","eq","selChanged","isExplicitToggle","some","tr","strictMarks","activeMarks","setStoredMarks"],"sourceRoot":"../../../../src","sources":["web/pmPlugins/StrictMarksPlugin.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,IAAI,QAAuC,kBAAkB;AACtE,SAASC,MAAM,EAAEC,SAAS,QAA0B,kBAAkB;AAEtE,MAAMC,kBAAkB,GAAG,CAAC,MAAM,EAAE,SAAS,CAAU;AAEvD,SAASC,6BAA6BA,CACpCC,MAAc,EACdC,KAAsB,EACL;EACjB,IAAIC,GAAG,GAAGD,KAAK,CAACE,KAAK,CAAC,CAAC;EACvB,KAAK,MAAMC,IAAI,IAAIN,kBAAkB,EAAE;IACrC,MAAMO,QAAQ,GAAGL,MAAM,CAACC,KAAK,CAACG,IAAI,CAAC;IACnC,IAAI,CAACC,QAAQ,EAAEC,OAAO,CAACJ,GAAG,CAAC,EAAE;IAC7BA,GAAG,GAAGA,GAAG,CAACK,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,KAAKJ,QAAQ,CAAC;EAC9C;EACA,OAAOH,GAAG;AACZ;AAEA,SAASQ,kCAAkCA,CACzCV,MAAc,EACdW,KAAkB,EACD;EACjB,MAAMC,UAAU,GAAGD,KAAK,CAACC,UAAU;EACnC,IAAI,CAACA,UAAU,EAAE;IACf,OAAO,EAAE;EACX;EACA,IAAIV,GAAG,GAAGU,UAAU,CAACX,KAAK;EAC1B,KAAK,MAAMG,IAAI,IAAIN,kBAAkB,EAAE;IACrC,MAAMO,QAAQ,GAAGL,MAAM,CAACC,KAAK,CAACG,IAAI,CAAC;IACnC,IAAI,CAACC,QAAQ,EAAEC,OAAO,CAACJ,GAAG,CAAC,EAAE;IAC7B,MAAMW,YAAY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I;QAEjC,MAAM;UAAE9B;QAAM,CAAC,GAAGc,SAAS;QAC3B,MAAMN,iBAAiB,GACrBH,QAAQ,CAACI,GAAG,CAACC,WAAW,CAACC,MAAM,KAAKL,QAAQ,CAACG,GAAG,CAACC,WAAW,CAACC,MAAM;QAErE,MAAMsB,WAAW,GAAG7B,kBAAkB,CACpCJ,KAAK,EACLK,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACVC,iBACF,CAAC;QAED,MAAM0B,WAAW,GAAG5B,QAAQ,CAACM,WAAW,IAAIZ,KAAK,CAACV,KAAK,CAAC,CAAC;QACzD,IAAIN,IAAI,CAACiC,OAAO,CAACgB,WAAW,EAAEC,WAAW,CAAC,EAAE,OAAO,IAAI;QAEvD,OAAO5B,QAAQ,CAAC0B,EAAE,CAACG,cAAc,CAACF,WAAW,CAAC;MAChD;IACF,CAAC,CAAC,CACH;EACH;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Extension } from '@tiptap/core';
|
|
4
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
5
|
+
import { HEADING_TAGS } from "../formats/EnrichedHeading.js";
|
|
6
|
+
function transactionStripBoldInCssBoldHeadings(state, htmlStyle) {
|
|
7
|
+
const boldType = state.schema.marks.bold;
|
|
8
|
+
if (!boldType) return null;
|
|
9
|
+
const tr = state.tr;
|
|
10
|
+
state.doc.descendants((node, pos) => {
|
|
11
|
+
if (node.type.name !== 'heading') return true;
|
|
12
|
+
const level = node.attrs.level;
|
|
13
|
+
if (level < 1 || level > HEADING_TAGS.length) return false;
|
|
14
|
+
const key = HEADING_TAGS[level - 1];
|
|
15
|
+
if (htmlStyle[key].bold) {
|
|
16
|
+
tr.removeMark(pos + 1, pos + node.nodeSize - 1, boldType);
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
});
|
|
20
|
+
return tr.steps.length > 0 ? tr : null;
|
|
21
|
+
}
|
|
22
|
+
export const StripBoldInStyledHeadingsPlugin = Extension.create({
|
|
23
|
+
name: 'stripBoldInStyledHeadings',
|
|
24
|
+
addOptions() {
|
|
25
|
+
return {
|
|
26
|
+
getHtmlStyle: () => {
|
|
27
|
+
throw new Error('StripBoldInStyledHeadingsPlugin.configure({ getHtmlStyle }) is required');
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
addCommands() {
|
|
32
|
+
return {
|
|
33
|
+
normalizeBoldInStyledHeadings: () => ({
|
|
34
|
+
state,
|
|
35
|
+
dispatch
|
|
36
|
+
}) => {
|
|
37
|
+
const htmlStyle = this.options.getHtmlStyle();
|
|
38
|
+
const tr = transactionStripBoldInCssBoldHeadings(state, htmlStyle);
|
|
39
|
+
if (!tr) return false;
|
|
40
|
+
if (dispatch) dispatch(tr);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
addProseMirrorPlugins() {
|
|
46
|
+
return [new Plugin({
|
|
47
|
+
key: new PluginKey('stripBoldInStyledHeadings'),
|
|
48
|
+
appendTransaction: (transactions, _oldState, newState) => {
|
|
49
|
+
if (!transactions.some(tr => tr.docChanged)) return;
|
|
50
|
+
const htmlStyle = this.options.getHtmlStyle();
|
|
51
|
+
return transactionStripBoldInCssBoldHeadings(newState, htmlStyle);
|
|
52
|
+
}
|
|
53
|
+
})];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=StripBoldInStyledHeadingsPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Extension","Plugin","PluginKey","HEADING_TAGS","transactionStripBoldInCssBoldHeadings","state","htmlStyle","boldType","schema","marks","bold","tr","doc","descendants","node","pos","type","name","level","attrs","length","key","removeMark","nodeSize","steps","StripBoldInStyledHeadingsPlugin","create","addOptions","getHtmlStyle","Error","addCommands","normalizeBoldInStyledHeadings","dispatch","options","addProseMirrorPlugins","appendTransaction","transactions","_oldState","newState","some","docChanged"],"sourceRoot":"../../../../src","sources":["web/pmPlugins/StripBoldInStyledHeadingsPlugin.ts"],"mappings":";;AAAA,SAASA,SAAS,QAA2B,cAAc;AAC3D,SACEC,MAAM,EACNC,SAAS,QAGJ,kBAAkB;AAEzB,SAASC,YAAY,QAAQ,+BAA4B;AAezD,SAASC,qCAAqCA,CAC5CC,KAAkB,EAClBC,SAA8B,EACV;EACpB,MAAMC,QAAQ,GAAGF,KAAK,CAACG,MAAM,CAACC,KAAK,CAACC,IAAI;EACxC,IAAI,CAACH,QAAQ,EAAE,OAAO,IAAI;EAE1B,MAAMI,EAAE,GAAGN,KAAK,CAACM,EAAE;EACnBN,KAAK,CAACO,GAAG,CAACC,WAAW,CAAC,CAACC,IAAI,EAAEC,GAAG,KAAK;IACnC,IAAID,IAAI,CAACE,IAAI,CAACC,IAAI,KAAK,SAAS,EAAE,OAAO,IAAI;IAC7C,MAAMC,KAAK,GAAGJ,IAAI,CAACK,KAAK,CAACD,KAAe;IACxC,IAAIA,KAAK,GAAG,CAAC,IAAIA,KAAK,GAAGf,YAAY,CAACiB,MAAM,EAAE,OAAO,KAAK;IAC1D,MAAMC,GAAG,GAAGlB,YAAY,CAACe,KAAK,GAAG,CAAC,CAAE;IACpC,IAAIZ,SAAS,CAACe,GAAG,CAAC,CAACX,IAAI,EAAE;MACvBC,EAAE,CAACW,UAAU,CAACP,GAAG,GAAG,CAAC,EAAEA,GAAG,GAAGD,IAAI,CAACS,QAAQ,GAAG,CAAC,EAAEhB,QAAQ,CAAC;IAC3D;IACA,OAAO,KAAK;EACd,CAAC,CAAC;EAEF,OAAOI,EAAE,CAACa,KAAK,CAACJ,MAAM,GAAG,CAAC,GAAGT,EAAE,GAAG,IAAI;AACxC;AAEA,OAAO,MAAMc,+BAA+B,GAC1CzB,SAAS,CAAC0B,MAAM,CAAyC;EACvDT,IAAI,EAAE,2BAA2B;EACjCU,UAAUA,CAAA,EAAG;IACX,OAAO;MACLC,YAAY,EAAEA,CAAA,KAAM;QAClB,MAAM,IAAIC,KAAK,CACb,yEACF,CAAC;MACH;IACF,CAAC;EACH,CAAC;EACDC,WAAWA,CAAA,EAAG;IACZ,OAAO;MACLC,6BAA6B,EAC3BA,CAAA,KACA,CAAC;QAAE1B,KAAK;QAAE2B;MAAuB,CAAC,KAAK;QACrC,MAAM1B,SAAS,GAAG,IAAI,CAAC2B,OAAO,CAACL,YAAY,CAAC,CAAC;QAC7C,MAAMjB,EAAE,GAAGP,qCAAqC,CAACC,KAAK,EAAEC,SAAS,CAAC;QAClE,IAAI,CAACK,EAAE,EAAE,OAAO,KAAK;QACrB,IAAIqB,QAAQ,EAAEA,QAAQ,CAACrB,EAAE,CAAC;QAC1B,OAAO,IAAI;MACb;IACJ,CAAC;EACH,CAAC;EACDuB,qBAAqBA,CAAA,EAAG;IACtB,OAAO,CACL,IAAIjC,MAAM,CAAC;MACToB,GAAG,EAAE,IAAInB,SAAS,CAAC,2BAA2B,CAAC;MAC/CiC,iBAAiB,EAAEA,CAACC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,KAAK;QACxD,IAAI,CAACF,YAAY,CAACG,IAAI,CAAE5B,EAAE,IAAKA,EAAE,CAAC6B,UAAU,CAAC,EAAE;QAC/C,MAAMlC,SAAS,GAAG,IAAI,CAAC2B,OAAO,CAACL,YAAY,CAAC,CAAC;QAE7C,OAAOxB,qCAAqC,CAACkC,QAAQ,EAAEhC,SAAS,CAAC;MACnE;IACF,CAAC,CAAC,CACH;EACH;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Extension } from '@tiptap/core';
|
|
4
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
5
|
+
export const StripMarksInCodeBlockPlugin = Extension.create({
|
|
6
|
+
name: 'stripMarksInCodeBlock',
|
|
7
|
+
addProseMirrorPlugins() {
|
|
8
|
+
return [new Plugin({
|
|
9
|
+
key: new PluginKey('stripMarksInCodeBlock'),
|
|
10
|
+
appendTransaction: (transactions, _oldState, newState) => {
|
|
11
|
+
if (!transactions.some(tr => tr.docChanged)) return;
|
|
12
|
+
const tr = newState.tr;
|
|
13
|
+
const allMarks = Object.values(newState.schema.marks);
|
|
14
|
+
newState.doc.descendants((node, pos) => {
|
|
15
|
+
if (node.type.name === 'codeBlock') {
|
|
16
|
+
allMarks.forEach(markType => {
|
|
17
|
+
tr.removeMark(pos + 1, pos + node.nodeSize - 1, markType);
|
|
18
|
+
});
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
});
|
|
23
|
+
return tr.steps.length > 0 ? tr : null;
|
|
24
|
+
}
|
|
25
|
+
})];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=StripMarksInCodeBlockPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Extension","Plugin","PluginKey","StripMarksInCodeBlockPlugin","create","name","addProseMirrorPlugins","key","appendTransaction","transactions","_oldState","newState","some","tr","docChanged","allMarks","Object","values","schema","marks","doc","descendants","node","pos","type","forEach","markType","removeMark","nodeSize","steps","length"],"sourceRoot":"../../../../src","sources":["web/pmPlugins/StripMarksInCodeBlockPlugin.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,MAAM,EAAEC,SAAS,QAAQ,kBAAkB;AAEpD,OAAO,MAAMC,2BAA2B,GAAGH,SAAS,CAACI,MAAM,CAAC;EAC1DC,IAAI,EAAE,uBAAuB;EAE7BC,qBAAqBA,CAAA,EAAG;IACtB,OAAO,CACL,IAAIL,MAAM,CAAC;MACTM,GAAG,EAAE,IAAIL,SAAS,CAAC,uBAAuB,CAAC;MAC3CM,iBAAiB,EAAEA,CAACC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,KAAK;QACxD,IAAI,CAACF,YAAY,CAACG,IAAI,CAAEC,EAAE,IAAKA,EAAE,CAACC,UAAU,CAAC,EAAE;QAE/C,MAAMD,EAAE,GAAGF,QAAQ,CAACE,EAAE;QAEtB,MAAME,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAACN,QAAQ,CAACO,MAAM,CAACC,KAAK,CAAC;QAErDR,QAAQ,CAACS,GAAG,CAACC,WAAW,CAAC,CAACC,IAAI,EAAEC,GAAG,KAAK;UACtC,IAAID,IAAI,CAACE,IAAI,CAACnB,IAAI,KAAK,WAAW,EAAE;YAClCU,QAAQ,CAACU,OAAO,CAAEC,QAAQ,IAAK;cAC7Bb,EAAE,CAACc,UAAU,CAACJ,GAAG,GAAG,CAAC,EAAEA,GAAG,GAAGD,IAAI,CAACM,QAAQ,GAAG,CAAC,EAAEF,QAAQ,CAAC;YAC3D,CAAC,CAAC;YACF,OAAO,KAAK;UACd;UAEA,OAAO,IAAI;QACb,CAAC,CAAC;QAEF,OAAOb,EAAE,CAACgB,KAAK,CAACC,MAAM,GAAG,CAAC,GAAGjB,EAAE,GAAG,IAAI;MACxC;IACF,CAAC,CAAC,CACH;EACH;AACF,CAAC,CAAC","ignoreList":[]}
|