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,54 @@
|
|
|
1
|
+
import Blockquote from '@tiptap/extension-blockquote';
|
|
2
|
+
import { toggleParagraphFormat } from './formatRules';
|
|
3
|
+
import {
|
|
4
|
+
wrappedBlockBackspace,
|
|
5
|
+
wrappedBlockEnter,
|
|
6
|
+
} from './wrappedBlockKeyboard';
|
|
7
|
+
|
|
8
|
+
declare module '@tiptap/core' {
|
|
9
|
+
interface Commands<ReturnType> {
|
|
10
|
+
codeBlock: {
|
|
11
|
+
toggleCodeBlock: () => ReturnType;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// We extend Blockquote, not CodeBlock: this node wraps (paragraph)+; TipTap's CodeBlock is a leaf block, not a paragraph container.
|
|
17
|
+
export const EnrichedCodeBlock = Blockquote.extend({
|
|
18
|
+
name: 'codeBlock',
|
|
19
|
+
content: '(paragraph)+',
|
|
20
|
+
|
|
21
|
+
parseHTML() {
|
|
22
|
+
return [{ tag: 'codeblock' }];
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
renderHTML({ HTMLAttributes }) {
|
|
26
|
+
return ['codeblock', HTMLAttributes, 0];
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
addCommands() {
|
|
30
|
+
return {
|
|
31
|
+
toggleCodeBlock:
|
|
32
|
+
() =>
|
|
33
|
+
({ editor, commands, chain }) =>
|
|
34
|
+
toggleParagraphFormat(
|
|
35
|
+
() => editor.isActive('codeBlock'),
|
|
36
|
+
() => commands.lift('codeBlock'),
|
|
37
|
+
(c) => c.toggleWrap('codeBlock'),
|
|
38
|
+
chain,
|
|
39
|
+
editor
|
|
40
|
+
),
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
addInputRules() {
|
|
45
|
+
return [];
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
addKeyboardShortcuts() {
|
|
49
|
+
return {
|
|
50
|
+
Enter: ({ editor }) => wrappedBlockEnter(editor, 'codeBlock'),
|
|
51
|
+
Backspace: ({ editor }) => wrappedBlockBackspace(editor, 'codeBlock'),
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Heading from '@tiptap/extension-heading';
|
|
2
|
+
import { toggleParagraphFormat } from './formatRules';
|
|
3
|
+
|
|
4
|
+
export const HEADING_LEVELS = [1, 2, 3, 4, 5, 6] as const;
|
|
5
|
+
|
|
6
|
+
export type HeadingTag = `h${(typeof HEADING_LEVELS)[number]}`;
|
|
7
|
+
|
|
8
|
+
export const HEADING_TAGS = HEADING_LEVELS.map(
|
|
9
|
+
(n) => `h${n}` as HeadingTag
|
|
10
|
+
) as readonly HeadingTag[];
|
|
11
|
+
|
|
12
|
+
export const EnrichedHeading = Heading.configure({
|
|
13
|
+
levels: [...HEADING_LEVELS],
|
|
14
|
+
}).extend({
|
|
15
|
+
addKeyboardShortcuts() {
|
|
16
|
+
return {};
|
|
17
|
+
},
|
|
18
|
+
addInputRules() {
|
|
19
|
+
return [];
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
addCommands() {
|
|
23
|
+
return {
|
|
24
|
+
...this.parent?.(),
|
|
25
|
+
toggleHeading:
|
|
26
|
+
(attrs) =>
|
|
27
|
+
({ editor, commands, chain }) =>
|
|
28
|
+
toggleParagraphFormat(
|
|
29
|
+
() => editor.isActive('heading', attrs),
|
|
30
|
+
() => commands.setParagraph(),
|
|
31
|
+
(c) => c.setHeading(attrs),
|
|
32
|
+
chain,
|
|
33
|
+
editor
|
|
34
|
+
),
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CommandProps } from '@tiptap/core';
|
|
2
|
+
import Image from '@tiptap/extension-image';
|
|
3
|
+
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
4
|
+
|
|
5
|
+
import { EnrichedImageNodeView } from './EnrichedImageNodeView';
|
|
6
|
+
import { isImageBlocked } from './formatRules';
|
|
7
|
+
|
|
8
|
+
export const EnrichedImage = Image.extend({
|
|
9
|
+
addOptions() {
|
|
10
|
+
const parent = this.parent?.();
|
|
11
|
+
return {
|
|
12
|
+
...parent,
|
|
13
|
+
inline: true,
|
|
14
|
+
allowBase64: false,
|
|
15
|
+
resize: false,
|
|
16
|
+
HTMLAttributes: parent?.HTMLAttributes ?? {},
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
renderHTML({ node }) {
|
|
21
|
+
return [
|
|
22
|
+
'img',
|
|
23
|
+
{
|
|
24
|
+
src: node.attrs.src,
|
|
25
|
+
width: node.attrs.width,
|
|
26
|
+
height: node.attrs.height,
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
addNodeView() {
|
|
32
|
+
return ReactNodeViewRenderer(EnrichedImageNodeView, { as: 'span' });
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
addInputRules() {
|
|
36
|
+
return [];
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
addCommands() {
|
|
40
|
+
return {
|
|
41
|
+
...this.parent?.(),
|
|
42
|
+
setImage:
|
|
43
|
+
(options: { src: string; width?: number; height?: number }) =>
|
|
44
|
+
({ editor, commands }: CommandProps) => {
|
|
45
|
+
if (isImageBlocked(editor)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return commands.insertContent({
|
|
49
|
+
type: this.name,
|
|
50
|
+
attrs: {
|
|
51
|
+
src: options.src,
|
|
52
|
+
width: options.width ?? null,
|
|
53
|
+
height: options.height ?? null,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { NodeViewWrapper, type ReactNodeViewProps } from '@tiptap/react';
|
|
2
|
+
import type { CSSProperties } from 'react';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { BROKEN_IMAGE_PATH_D } from '../constants/brokenImageGlyph';
|
|
5
|
+
|
|
6
|
+
const IMAGE_FALLBACK_SIZE = 80;
|
|
7
|
+
|
|
8
|
+
function BrokenImageGlyph() {
|
|
9
|
+
return (
|
|
10
|
+
<svg
|
|
11
|
+
viewBox="0 0 960 960"
|
|
12
|
+
width="100%"
|
|
13
|
+
height="100%"
|
|
14
|
+
preserveAspectRatio="none"
|
|
15
|
+
aria-hidden
|
|
16
|
+
focusable="false"
|
|
17
|
+
className="eti-inline-image-broken-glyph"
|
|
18
|
+
>
|
|
19
|
+
<path fill="currentColor" d={BROKEN_IMAGE_PATH_D} />
|
|
20
|
+
</svg>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function dim(value: unknown): number | undefined {
|
|
25
|
+
if (value == null) return undefined;
|
|
26
|
+
if (typeof value === 'number' && !Number.isNaN(value)) return value;
|
|
27
|
+
const n = parseFloat(String(value));
|
|
28
|
+
return Number.isNaN(n) ? undefined : n;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function EnrichedImageNodeView({ node }: ReactNodeViewProps) {
|
|
32
|
+
const src = ((node.attrs.src as string | null | undefined) ?? '').trim();
|
|
33
|
+
const rawW = dim(node.attrs.width);
|
|
34
|
+
const rawH = dim(node.attrs.height);
|
|
35
|
+
const [errored, setErrored] = useState(false);
|
|
36
|
+
const showPlaceholder = src.length === 0 || errored;
|
|
37
|
+
|
|
38
|
+
const placeholderW = rawW ?? IMAGE_FALLBACK_SIZE;
|
|
39
|
+
const placeholderH = rawH ?? IMAGE_FALLBACK_SIZE;
|
|
40
|
+
|
|
41
|
+
const sizeStyle: CSSProperties = {
|
|
42
|
+
width: placeholderW,
|
|
43
|
+
height: placeholderH,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
if (showPlaceholder) {
|
|
47
|
+
return (
|
|
48
|
+
<NodeViewWrapper
|
|
49
|
+
as="span"
|
|
50
|
+
className="eti-inline-image eti-inline-image--placeholder"
|
|
51
|
+
style={sizeStyle}
|
|
52
|
+
data-eti-image-placeholder=""
|
|
53
|
+
>
|
|
54
|
+
<BrokenImageGlyph />
|
|
55
|
+
</NodeViewWrapper>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let imgDims: { width?: number; height?: number };
|
|
60
|
+
let imgStyle: CSSProperties | undefined;
|
|
61
|
+
|
|
62
|
+
if (rawW != null && rawH != null) {
|
|
63
|
+
imgDims = { width: rawW, height: rawH };
|
|
64
|
+
imgStyle = undefined;
|
|
65
|
+
} else if (rawH != null) {
|
|
66
|
+
imgDims = { height: rawH };
|
|
67
|
+
imgStyle = { width: 'auto' };
|
|
68
|
+
} else {
|
|
69
|
+
imgDims = { width: rawW ?? IMAGE_FALLBACK_SIZE };
|
|
70
|
+
imgStyle = { height: 'auto' };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<NodeViewWrapper as="span" className="eti-inline-image">
|
|
75
|
+
<img
|
|
76
|
+
{...imgDims}
|
|
77
|
+
src={src}
|
|
78
|
+
alt=""
|
|
79
|
+
className="eti-inline-image-img"
|
|
80
|
+
style={imgStyle}
|
|
81
|
+
contentEditable={false}
|
|
82
|
+
draggable={false}
|
|
83
|
+
onError={() => setErrored(true)}
|
|
84
|
+
/>
|
|
85
|
+
</NodeViewWrapper>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Italic from '@tiptap/extension-italic';
|
|
2
|
+
|
|
3
|
+
export const EnrichedItalic = Italic.extend({
|
|
4
|
+
addInputRules() {
|
|
5
|
+
return [];
|
|
6
|
+
},
|
|
7
|
+
addKeyboardShortcuts() {
|
|
8
|
+
return {};
|
|
9
|
+
},
|
|
10
|
+
parseHTML() {
|
|
11
|
+
return [{ tag: 'i' }];
|
|
12
|
+
},
|
|
13
|
+
renderHTML({ HTMLAttributes }) {
|
|
14
|
+
return ['i', HTMLAttributes, 0];
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import Link, { type LinkOptions } from '@tiptap/extension-link';
|
|
2
|
+
import { mergeAttributes, type CommandProps } from '@tiptap/core';
|
|
3
|
+
import type { Editor } from '@tiptap/react';
|
|
4
|
+
|
|
5
|
+
import { nativePosToTiptapPos } from '../positionMapping';
|
|
6
|
+
import { isLinkBlocked } from './formatRules';
|
|
7
|
+
import { findAutolinkRangesInWord } from '../pmPlugins/AutolinkPlugin/autolinkRegex';
|
|
8
|
+
|
|
9
|
+
function isFullLinkMatch(text: string, linkRegex: RegExp | undefined): boolean {
|
|
10
|
+
const ranges = findAutolinkRangesInWord(text, linkRegex);
|
|
11
|
+
return ranges.some((r) => r.start === 0 && r.endExclusive === text.length);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const EnrichedLink = Link.extend<
|
|
15
|
+
LinkOptions & { getLinkRegex: () => RegExp | null | undefined }
|
|
16
|
+
>({
|
|
17
|
+
excludes: 'link code',
|
|
18
|
+
|
|
19
|
+
parseHTML() {
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
tag: 'a[href]',
|
|
23
|
+
getAttrs: (node: string | HTMLElement) => {
|
|
24
|
+
if (typeof node === 'string') return null;
|
|
25
|
+
const href = node.getAttribute('href');
|
|
26
|
+
if (!href || /^javascript:/i.test(href)) return false;
|
|
27
|
+
return null;
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
addAttributes() {
|
|
34
|
+
return {
|
|
35
|
+
...this.parent?.(),
|
|
36
|
+
auto: {
|
|
37
|
+
default: false,
|
|
38
|
+
parseHTML: (el) => {
|
|
39
|
+
const href = el.getAttribute('href');
|
|
40
|
+
const textContent = el.textContent;
|
|
41
|
+
if (!href || href !== textContent) return false;
|
|
42
|
+
|
|
43
|
+
const linkRegex = this.options.getLinkRegex();
|
|
44
|
+
if (linkRegex === null) return false;
|
|
45
|
+
|
|
46
|
+
return isFullLinkMatch(href, linkRegex);
|
|
47
|
+
},
|
|
48
|
+
renderHTML: () => {
|
|
49
|
+
return {};
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
renderHTML({ HTMLAttributes }) {
|
|
56
|
+
return [
|
|
57
|
+
'a',
|
|
58
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
59
|
+
0,
|
|
60
|
+
];
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
addOptions() {
|
|
64
|
+
const parent = this.parent?.()!;
|
|
65
|
+
return {
|
|
66
|
+
...parent,
|
|
67
|
+
openOnClick: false,
|
|
68
|
+
autolink: false,
|
|
69
|
+
linkOnPaste: false,
|
|
70
|
+
HTMLAttributes: {
|
|
71
|
+
...parent.HTMLAttributes,
|
|
72
|
+
target: null,
|
|
73
|
+
rel: null,
|
|
74
|
+
},
|
|
75
|
+
getLinkRegex: () => {
|
|
76
|
+
throw new Error('EnrichedLink.configure({ getLinkRegex }) is required');
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
addKeyboardShortcuts() {
|
|
82
|
+
return {};
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
addCommands() {
|
|
86
|
+
const parent = this.parent?.();
|
|
87
|
+
return {
|
|
88
|
+
...parent,
|
|
89
|
+
setLink: (attributes) => (props: CommandProps) => {
|
|
90
|
+
if (isLinkBlocked(props.editor)) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
return parent?.setLink?.(attributes)(props) ?? false;
|
|
94
|
+
},
|
|
95
|
+
toggleLink: (attributes) => (props: CommandProps) => {
|
|
96
|
+
if (isLinkBlocked(props.editor)) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
return parent?.toggleLink?.(attributes)(props) ?? false;
|
|
100
|
+
},
|
|
101
|
+
unsetLink: () => (props: CommandProps) => {
|
|
102
|
+
if (isLinkBlocked(props.editor)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return parent?.unsetLink?.()(props) ?? false;
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
addPasteRules() {
|
|
111
|
+
return [];
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export function removeLink(editor: Editor, start: number, end: number) {
|
|
116
|
+
const { doc, selection: selectionBefore } = editor.state;
|
|
117
|
+
const from = nativePosToTiptapPos(doc, start);
|
|
118
|
+
const to = nativePosToTiptapPos(doc, end);
|
|
119
|
+
editor
|
|
120
|
+
.chain()
|
|
121
|
+
.focus()
|
|
122
|
+
.setTextSelection({ from, to })
|
|
123
|
+
.unsetLink()
|
|
124
|
+
.command(({ tr }) => {
|
|
125
|
+
const mapped = selectionBefore.map(tr.doc, tr.mapping);
|
|
126
|
+
if (mapped) {
|
|
127
|
+
tr.setSelection(mapped);
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
})
|
|
131
|
+
.run();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function setLink(
|
|
135
|
+
editor: Editor,
|
|
136
|
+
start: number,
|
|
137
|
+
end: number,
|
|
138
|
+
text: string,
|
|
139
|
+
url: string
|
|
140
|
+
) {
|
|
141
|
+
if (url.length === 0 || text.length === 0) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const { state } = editor;
|
|
145
|
+
const doc = state.doc;
|
|
146
|
+
const from = nativePosToTiptapPos(doc, start);
|
|
147
|
+
const to = nativePosToTiptapPos(doc, end);
|
|
148
|
+
|
|
149
|
+
if (isRangeLinkBlocked(editor, from, to)) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const linkType = state.schema.marks.link;
|
|
154
|
+
if (!linkType) return;
|
|
155
|
+
const linkMark = linkType.create({ href: url });
|
|
156
|
+
editor
|
|
157
|
+
.chain()
|
|
158
|
+
.focus()
|
|
159
|
+
.command(({ tr, state: s }) => {
|
|
160
|
+
if (from === to) {
|
|
161
|
+
const marksAtRangeStart = doc.resolve(from).marks();
|
|
162
|
+
const marksWithLink = linkMark.addToSet(marksAtRangeStart);
|
|
163
|
+
tr.insert(from, s.schema.text(text, marksWithLink));
|
|
164
|
+
} else {
|
|
165
|
+
const currentText = doc.textBetween(from, to);
|
|
166
|
+
|
|
167
|
+
if (text !== currentText) {
|
|
168
|
+
const marksAtRangeStart = doc.resolve(from).marks();
|
|
169
|
+
const marksWithLink = linkMark.addToSet(marksAtRangeStart);
|
|
170
|
+
tr.replaceWith(from, to, s.schema.text(text, marksWithLink));
|
|
171
|
+
} else {
|
|
172
|
+
tr.addMark(from, to, linkMark);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return true;
|
|
176
|
+
})
|
|
177
|
+
.run();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// We use this function instead of relying on editor.isActive('...') because it
|
|
181
|
+
// checks the current selection, not from and to passed by user
|
|
182
|
+
function isRangeLinkBlocked(editor: Editor, from: number, to: number): boolean {
|
|
183
|
+
const { doc, schema } = editor.state;
|
|
184
|
+
|
|
185
|
+
const hasInlineCode =
|
|
186
|
+
schema.marks.code && doc.rangeHasMark(from, to, schema.marks.code);
|
|
187
|
+
|
|
188
|
+
if (hasInlineCode) {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
let hasBlockedNode = false;
|
|
193
|
+
const blockedNodes = ['codeBlock', 'image'];
|
|
194
|
+
doc.nodesBetween(from, to, (node) => {
|
|
195
|
+
if (hasBlockedNode) return false;
|
|
196
|
+
if (blockedNodes.includes(node.type.name)) {
|
|
197
|
+
hasBlockedNode = true;
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
return true;
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
return hasBlockedNode;
|
|
204
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ListItem } from '@tiptap/extension-list';
|
|
2
|
+
|
|
3
|
+
import { listBackspace, listEnter } from './listKeyboard';
|
|
4
|
+
|
|
5
|
+
const LIST_WRAPPERS = ['unorderedList', 'orderedList'] as const;
|
|
6
|
+
|
|
7
|
+
export const EnrichedListItem = ListItem.extend({
|
|
8
|
+
content: 'paragraph',
|
|
9
|
+
|
|
10
|
+
addKeyboardShortcuts() {
|
|
11
|
+
return {
|
|
12
|
+
Enter: ({ editor }) => listEnter(editor, 'listItem'),
|
|
13
|
+
Backspace: ({ editor }) =>
|
|
14
|
+
listBackspace(editor, 'listItem', LIST_WRAPPERS),
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Mark, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
export const EXCLUDED_MARKS = ['link', 'code', 'mention'];
|
|
4
|
+
|
|
5
|
+
export const EnrichedMention = Mark.create({
|
|
6
|
+
name: 'mention',
|
|
7
|
+
inclusive: false,
|
|
8
|
+
excludes: EXCLUDED_MARKS.join(' '),
|
|
9
|
+
priority: 1000,
|
|
10
|
+
|
|
11
|
+
addAttributes() {
|
|
12
|
+
return {
|
|
13
|
+
indicator: {
|
|
14
|
+
default: '@',
|
|
15
|
+
},
|
|
16
|
+
text: {
|
|
17
|
+
default: '',
|
|
18
|
+
},
|
|
19
|
+
attributes: {
|
|
20
|
+
default: {},
|
|
21
|
+
parseHTML(el: HTMLElement): Record<string, string> {
|
|
22
|
+
const out: Record<string, string> = {};
|
|
23
|
+
for (let i = 0; i < el.attributes.length; i++) {
|
|
24
|
+
const attr = el.attributes.item(i);
|
|
25
|
+
if (!attr) continue;
|
|
26
|
+
if (attr.name === 'text' || attr.name === 'indicator') continue;
|
|
27
|
+
out[attr.name] = attr.value;
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
},
|
|
31
|
+
renderHTML(attrs: Record<string, unknown>): Record<string, string> {
|
|
32
|
+
return (attrs.attributes ?? {}) as Record<string, string>;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
parseHTML() {
|
|
39
|
+
return [{ tag: 'mention' }];
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
renderHTML({ mark }) {
|
|
43
|
+
return [
|
|
44
|
+
'mention',
|
|
45
|
+
mergeAttributes(
|
|
46
|
+
{
|
|
47
|
+
text: mark.attrs.text as string,
|
|
48
|
+
indicator: mark.attrs.indicator as string,
|
|
49
|
+
},
|
|
50
|
+
(mark.attrs.attributes ?? {}) as Record<string, string>
|
|
51
|
+
),
|
|
52
|
+
0,
|
|
53
|
+
];
|
|
54
|
+
},
|
|
55
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { wrappingInputRule } from '@tiptap/core';
|
|
2
|
+
import { OrderedList } from '@tiptap/extension-list';
|
|
3
|
+
|
|
4
|
+
import { applyWrappingListToSelection } from './applyWrappingListToSelection';
|
|
5
|
+
import { withPreservedAlignment } from './formatRules';
|
|
6
|
+
|
|
7
|
+
const ORDERED_LIST_INPUT_REGEX = /^1\.\s$/;
|
|
8
|
+
|
|
9
|
+
export const EnrichedOrderedList = OrderedList.extend({
|
|
10
|
+
addInputRules() {
|
|
11
|
+
return [
|
|
12
|
+
wrappingInputRule({
|
|
13
|
+
find: ORDERED_LIST_INPUT_REGEX,
|
|
14
|
+
type: this.type,
|
|
15
|
+
}),
|
|
16
|
+
];
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
addKeyboardShortcuts() {
|
|
20
|
+
return {};
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
addCommands() {
|
|
24
|
+
return {
|
|
25
|
+
toggleOrderedList:
|
|
26
|
+
() =>
|
|
27
|
+
({ editor, chain }) => {
|
|
28
|
+
if (editor.isActive('orderedList')) {
|
|
29
|
+
return withPreservedAlignment(editor, chain(), (c) =>
|
|
30
|
+
c.clearNodes().setParagraph()
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return applyWrappingListToSelection(
|
|
35
|
+
editor,
|
|
36
|
+
chain,
|
|
37
|
+
'orderedList',
|
|
38
|
+
'listItem'
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Strike from '@tiptap/extension-strike';
|
|
2
|
+
|
|
3
|
+
export const EnrichedStrike = Strike.extend({
|
|
4
|
+
addInputRules() {
|
|
5
|
+
return [];
|
|
6
|
+
},
|
|
7
|
+
addKeyboardShortcuts() {
|
|
8
|
+
return {};
|
|
9
|
+
},
|
|
10
|
+
parseHTML() {
|
|
11
|
+
return [{ tag: 's' }];
|
|
12
|
+
},
|
|
13
|
+
renderHTML({ HTMLAttributes }) {
|
|
14
|
+
return ['s', HTMLAttributes, 0];
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { isTextSelection } from '@tiptap/core';
|
|
2
|
+
import { TextAlign } from '@tiptap/extension-text-align';
|
|
3
|
+
|
|
4
|
+
export const EnrichedTextAlign = TextAlign.extend({
|
|
5
|
+
addCommands() {
|
|
6
|
+
return {
|
|
7
|
+
...this.parent?.(),
|
|
8
|
+
setTextAlign: (alignment) => (props) => {
|
|
9
|
+
const { state, dispatch, tr } = props;
|
|
10
|
+
|
|
11
|
+
if (!this.options.alignments.includes(alignment)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { $from } = state.selection;
|
|
16
|
+
let listNode: typeof $from.parent | null = null;
|
|
17
|
+
let listPos = -1;
|
|
18
|
+
|
|
19
|
+
// Walk up the tree to see if the cursor is inside a list wrapper
|
|
20
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
21
|
+
const node = $from.node(depth);
|
|
22
|
+
if (
|
|
23
|
+
['orderedList', 'unorderedList', 'checkboxList'].includes(
|
|
24
|
+
node.type.name
|
|
25
|
+
)
|
|
26
|
+
) {
|
|
27
|
+
listNode = node;
|
|
28
|
+
listPos = $from.before(depth);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// If in a list, manually apply the alignment to the parent wrapper
|
|
34
|
+
if (listNode) {
|
|
35
|
+
if (dispatch) {
|
|
36
|
+
tr.setNodeMarkup(listPos, undefined, {
|
|
37
|
+
...listNode.attrs,
|
|
38
|
+
textAlign: alignment,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// If not in a list, fire the original Tiptap command
|
|
45
|
+
return this.parent?.().setTextAlign?.(alignment)(props) ?? false;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
addKeyboardShortcuts() {
|
|
51
|
+
return {
|
|
52
|
+
...this.parent?.(),
|
|
53
|
+
Backspace: () => {
|
|
54
|
+
const { selection } = this.editor.state;
|
|
55
|
+
|
|
56
|
+
if (!selection.empty || !isTextSelection(selection)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const { $cursor } = selection;
|
|
61
|
+
|
|
62
|
+
if (!$cursor || !this.editor.isEmpty) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const currentAlignment = $cursor.parent.attrs.textAlign;
|
|
67
|
+
const hasAlignment = currentAlignment && currentAlignment !== 'auto';
|
|
68
|
+
|
|
69
|
+
// If the input is empty and has an alignment, clear the alignment
|
|
70
|
+
if (hasAlignment) {
|
|
71
|
+
return this.editor.commands.unsetTextAlign();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return false;
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
}).configure({
|
|
79
|
+
types: [
|
|
80
|
+
'paragraph',
|
|
81
|
+
'heading',
|
|
82
|
+
'orderedList',
|
|
83
|
+
'unorderedList',
|
|
84
|
+
'checkboxList',
|
|
85
|
+
],
|
|
86
|
+
defaultAlignment: null,
|
|
87
|
+
alignments: ['left', 'center', 'right', 'justify'],
|
|
88
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Underline from '@tiptap/extension-underline';
|
|
2
|
+
|
|
3
|
+
export const EnrichedUnderline = Underline.extend({
|
|
4
|
+
addInputRules() {
|
|
5
|
+
return [];
|
|
6
|
+
},
|
|
7
|
+
addKeyboardShortcuts() {
|
|
8
|
+
return {};
|
|
9
|
+
},
|
|
10
|
+
parseHTML() {
|
|
11
|
+
return [{ tag: 'u' }];
|
|
12
|
+
},
|
|
13
|
+
renderHTML({ HTMLAttributes }) {
|
|
14
|
+
return ['u', HTMLAttributes, 0];
|
|
15
|
+
},
|
|
16
|
+
});
|