react-native-enriched-html 0.0.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +402 -0
- package/ReactNativeEnrichedHtml.podspec +31 -0
- package/android/build.gradle +106 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +203 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +74 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextViewManagerDelegate.java +70 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextViewManagerInterface.java +31 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/EventEmitters.cpp +456 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/EventEmitters.h +410 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/Props.cpp +272 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/Props.h +1595 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/ShadowNodes.h +23 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/ReactNativeEnrichedSpec/States.h +20 -0
- package/android/gradle.properties +5 -0
- package/android/lint.gradle +70 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/swmansion/enriched/ReactNativeEnrichedPackage.kt +22 -0
- package/android/src/main/java/com/swmansion/enriched/common/AllowFontScaling.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/common/AsyncDrawable.kt +126 -0
- package/android/src/main/java/com/swmansion/enriched/common/CheckboxDrawable.kt +81 -0
- package/android/src/main/java/com/swmansion/enriched/common/EnrichedConstants.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/common/EnrichedStyle.kt +57 -0
- package/android/src/main/java/com/swmansion/enriched/common/ForceRedrawSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/common/GumboNormalizer.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/common/MentionStyle.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/common/ResourceManager.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedParser.java +1034 -0
- package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt +82 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedAlignmentSpan.kt +19 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedBlockQuoteSpan.kt +53 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedBoldSpan.kt +12 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedCheckboxListSpan.kt +92 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedCodeBlockSpan.kt +81 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH1Span.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH2Span.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH3Span.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH4Span.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH5Span.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedH6Span.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedImageSpan.kt +185 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedInlineCodeSpan.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedItalicSpan.kt +12 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedLinkSpan.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedMentionSpan.kt +35 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedOrderedListSpan.kt +79 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedStrikeThroughSpan.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedUnderlineSpan.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/EnrichedUnorderedListSpan.kt +62 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedBlockSpan.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedHeadingSpan.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedInlineSpan.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedParagraphSpan.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedSpan.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/common/spans/interfaces/EnrichedZeroWidthSpaceSpan.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextMovementMethod.kt +75 -0
- package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextSpanFactory.kt +83 -0
- package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextStyle.kt +202 -0
- package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextView.kt +361 -0
- package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextViewManager.kt +157 -0
- package/android/src/main/java/com/swmansion/enriched/text/MeasurementStore.kt +170 -0
- package/android/src/main/java/com/swmansion/enriched/text/events/OnLinkPressEvent.kt +23 -0
- package/android/src/main/java/com/swmansion/enriched/text/events/OnMentionPressEvent.kt +32 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextAlignmentSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextBlockQuoteSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextBoldSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextCheckboxListSpan.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextCodeBlockSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH1Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH2Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH3Span.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH4Span.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH5Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextH6Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextImageSpan.kt +57 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextInlineCodeSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextItalicSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextLinkSpan.kt +41 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextMentionSpan.kt +63 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextOrderedListSpan.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextStrikeThroughSpan.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextUnderlineSpan.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextUnorderedListSpan.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/interfaces/EnrichedTextClickableSpan.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/text/spans/interfaces/EnrichedTextSpan.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputConnectionWrapper.kt +140 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputSpannableFactory.kt +85 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt +1141 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewLayoutManager.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewManager.kt +500 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/MeasurementStore.kt +230 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/MentionHandler.kt +55 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeHtmlEvent.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeSelectionEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeStateEvent.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnChangeTextEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnContextMenuItemPressEvent.kt +35 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnInputBlurEvent.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnInputFocusEvent.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnInputKeyPressEvent.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnLinkDetectedEvent.kt +32 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnMentionDetectedEvent.kt +30 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnMentionEvent.kt +34 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnPasteImagesEvent.kt +47 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnRequestHtmlResultEvent.kt +32 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/events/OnSubmitEditingEvent.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputAlignmentSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputBlockQuoteSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputBoldSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputCheckboxListSpan.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputCodeBlockSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH1Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH2Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH3Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH4Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH5Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputH6Span.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputImageSpan.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputInlineCodeSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputItalicSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputLinkSpan.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputMentionSpan.kt +18 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputOrderedListSpan.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputStrikeThroughSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputUnderlineSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputUnorderedListSpan.kt +14 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedLineHeightSpan.kt +45 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedSpans.kt +240 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/spans/interfaces/EnrichedInputSpan.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/AlignmentStyles.kt +367 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/HtmlStyle.kt +371 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/InlineStyles.kt +232 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ListStyles.kt +260 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt +439 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt +408 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedEditableFactory.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSelection.kt +340 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpanState.kt +318 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannable.kt +156 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannableStringBuilder.kt +59 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/RichContentReceiver.kt +127 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/ShortcutsHandler.kt +150 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/StyleUtils.kt +51 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/utils/Utils.kt +106 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedSpanWatcher.kt +109 -0
- package/android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedTextWatcher.kt +106 -0
- package/android/src/main/new_arch/CMakeLists.txt +62 -0
- package/android/src/main/new_arch/GumboNormalizerJni.cpp +14 -0
- package/android/src/main/new_arch/ReactNativeEnrichedSpec.cpp +11 -0
- package/android/src/main/new_arch/ReactNativeEnrichedSpec.h +16 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextComponentDescriptor.h +32 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputComponentDescriptor.h +35 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputMeasurementManager.cpp +53 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputMeasurementManager.h +25 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputShadowNode.cpp +35 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputShadowNode.h +53 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputState.cpp +9 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextInputState.h +24 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextMeasurementManager.cpp +45 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextMeasurementManager.h +25 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextShadowNode.cpp +21 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/EnrichedTextShadowNode.h +39 -0
- package/android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/conversions.h +44 -0
- package/android/src/main/res/drawable/broken_image.xml +10 -0
- package/cpp/CMakeLists.txt +50 -0
- package/cpp/GumboParser/GumboParser.h +34043 -0
- package/cpp/README.md +59 -0
- package/cpp/parser/GumboNormalizer.c +915 -0
- package/cpp/parser/GumboParser.cpp +16 -0
- package/cpp/parser/GumboParser.hpp +23 -0
- package/cpp/tests/GumboParserTest.cpp +457 -0
- package/ios/EnrichedTextInputView.h +54 -0
- package/ios/EnrichedTextInputView.mm +2170 -0
- package/ios/EnrichedTextInputViewManager.mm +13 -0
- package/ios/EnrichedTextView.h +35 -0
- package/ios/EnrichedTextView.mm +806 -0
- package/ios/EnrichedTextViewManager.mm +13 -0
- package/ios/config/EnrichedConfig.h +114 -0
- package/ios/config/EnrichedConfig.mm +727 -0
- package/ios/enrichedInputTextView/EnrichedInputTextView.h +6 -0
- package/ios/enrichedInputTextView/EnrichedInputTextView.mm +334 -0
- package/ios/enrichedTextTextView/EnrichedTextTextView.h +16 -0
- package/ios/enrichedTextTextView/EnrichedTextTextView.mm +71 -0
- package/ios/extensions/ColorExtension.h +8 -0
- package/ios/extensions/ColorExtension.mm +48 -0
- package/ios/extensions/FontExtension.h +11 -0
- package/ios/extensions/FontExtension.mm +72 -0
- package/ios/extensions/ImageExtension.h +33 -0
- package/ios/extensions/ImageExtension.mm +176 -0
- package/ios/extensions/LayoutManagerExtension.h +6 -0
- package/ios/extensions/LayoutManagerExtension.mm +454 -0
- package/ios/extensions/StringExtension.h +15 -0
- package/ios/extensions/StringExtension.mm +69 -0
- package/ios/generated/ReactNativeEnrichedSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/ReactNativeEnrichedSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/ReactNativeEnrichedSpec/EventEmitters.cpp +456 -0
- package/ios/generated/ReactNativeEnrichedSpec/EventEmitters.h +410 -0
- package/ios/generated/ReactNativeEnrichedSpec/Props.cpp +272 -0
- package/ios/generated/ReactNativeEnrichedSpec/Props.h +1595 -0
- package/ios/generated/ReactNativeEnrichedSpec/RCTComponentViewHelpers.h +570 -0
- package/ios/generated/ReactNativeEnrichedSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/ReactNativeEnrichedSpec/ShadowNodes.h +23 -0
- package/ios/generated/ReactNativeEnrichedSpec/States.cpp +16 -0
- package/ios/generated/ReactNativeEnrichedSpec/States.h +20 -0
- package/ios/htmlParser/HtmlParser.h +11 -0
- package/ios/htmlParser/HtmlParser.mm +1468 -0
- package/ios/inputAttributesManager/InputAttributesManager.h +18 -0
- package/ios/inputAttributesManager/InputAttributesManager.mm +222 -0
- package/ios/inputHtmlParser/InputHtmlParser.h +10 -0
- package/ios/inputHtmlParser/InputHtmlParser.mm +225 -0
- package/ios/interfaces/AlignmentEntry.h +9 -0
- package/ios/interfaces/AlignmentEntry.mm +4 -0
- package/ios/interfaces/AttributeEntry.h +9 -0
- package/ios/interfaces/AttributeEntry.mm +4 -0
- package/ios/interfaces/BaseStyleProtocol.h +17 -0
- package/ios/interfaces/EnrichedTextStyleHeaders.h +62 -0
- package/ios/interfaces/EnrichedViewHost.h +26 -0
- package/ios/interfaces/ImageAttachment.h +11 -0
- package/ios/interfaces/ImageAttachment.mm +107 -0
- package/ios/interfaces/ImageData.h +10 -0
- package/ios/interfaces/ImageData.mm +4 -0
- package/ios/interfaces/LinkData.h +11 -0
- package/ios/interfaces/LinkData.mm +43 -0
- package/ios/interfaces/LinkRegexConfig.h +19 -0
- package/ios/interfaces/LinkRegexConfig.mm +37 -0
- package/ios/interfaces/MediaAttachment.h +23 -0
- package/ios/interfaces/MediaAttachment.mm +31 -0
- package/ios/interfaces/MentionParams.h +8 -0
- package/ios/interfaces/MentionParams.mm +4 -0
- package/ios/interfaces/MentionStyleProps.h +17 -0
- package/ios/interfaces/MentionStyleProps.mm +80 -0
- package/ios/interfaces/StyleBase.h +38 -0
- package/ios/interfaces/StyleBase.mm +279 -0
- package/ios/interfaces/StyleHeaders.h +110 -0
- package/ios/interfaces/StylePair.h +9 -0
- package/ios/interfaces/StylePair.mm +4 -0
- package/ios/interfaces/StyleTypeEnum.h +27 -0
- package/ios/interfaces/TextDecorationLineEnum.h +6 -0
- package/ios/interfaces/TextDecorationLineEnum.mm +4 -0
- package/ios/internals/EnrichedTextComponentDescriptor.h +19 -0
- package/ios/internals/EnrichedTextInputViewComponentDescriptor.h +19 -0
- package/ios/internals/EnrichedTextInputViewShadowNode.h +44 -0
- package/ios/internals/EnrichedTextInputViewShadowNode.mm +103 -0
- package/ios/internals/EnrichedTextInputViewState.cpp +10 -0
- package/ios/internals/EnrichedTextInputViewState.h +22 -0
- package/ios/internals/EnrichedTextViewShadowNode.h +34 -0
- package/ios/internals/EnrichedTextViewShadowNode.mm +72 -0
- package/ios/internals/EnrichedTextViewState.cpp +7 -0
- package/ios/internals/EnrichedTextViewState.h +18 -0
- package/ios/styles/AlignmentStyle.mm +203 -0
- package/ios/styles/BlockQuoteStyle.mm +54 -0
- package/ios/styles/BoldStyle.mm +37 -0
- package/ios/styles/CheckboxListStyle.mm +154 -0
- package/ios/styles/CodeBlockStyle.mm +49 -0
- package/ios/styles/EnrichedTextStyles.mm +61 -0
- package/ios/styles/H1Style.mm +20 -0
- package/ios/styles/H2Style.mm +20 -0
- package/ios/styles/H3Style.mm +20 -0
- package/ios/styles/H4Style.mm +20 -0
- package/ios/styles/H5Style.mm +20 -0
- package/ios/styles/H6Style.mm +20 -0
- package/ios/styles/HeadingStyleBase.mm +96 -0
- package/ios/styles/ImageStyle.mm +150 -0
- package/ios/styles/InlineCodeStyle.mm +65 -0
- package/ios/styles/ItalicStyle.mm +37 -0
- package/ios/styles/LinkStyle.mm +532 -0
- package/ios/styles/MentionStyle.mm +541 -0
- package/ios/styles/OrderedListStyle.mm +48 -0
- package/ios/styles/StrikethroughStyle.mm +25 -0
- package/ios/styles/UnderlineStyle.mm +24 -0
- package/ios/styles/UnorderedListStyle.mm +48 -0
- package/ios/textHtmlParser/TextHtmlParser.h +10 -0
- package/ios/textHtmlParser/TextHtmlParser.mm +181 -0
- package/ios/utils/AlignmentUtils.h +20 -0
- package/ios/utils/AlignmentUtils.mm +111 -0
- package/ios/utils/AttachmentLayoutUtils.h +24 -0
- package/ios/utils/AttachmentLayoutUtils.mm +144 -0
- package/ios/utils/CheckboxHitTestUtils.h +10 -0
- package/ios/utils/CheckboxHitTestUtils.mm +122 -0
- package/ios/utils/DotReplacementUtils.h +10 -0
- package/ios/utils/DotReplacementUtils.mm +68 -0
- package/ios/utils/EnrichedTextTouchHandler.h +14 -0
- package/ios/utils/EnrichedTextTouchHandler.mm +152 -0
- package/ios/utils/KeyboardUtils.h +7 -0
- package/ios/utils/KeyboardUtils.mm +30 -0
- package/ios/utils/OccurenceUtils.h +44 -0
- package/ios/utils/OccurenceUtils.mm +185 -0
- package/ios/utils/ParagraphAttributesUtils.h +18 -0
- package/ios/utils/ParagraphAttributesUtils.mm +289 -0
- package/ios/utils/RangeUtils.h +12 -0
- package/ios/utils/RangeUtils.mm +183 -0
- package/ios/utils/ShortcutsUtils.h +21 -0
- package/ios/utils/ShortcutsUtils.mm +486 -0
- package/ios/utils/StyleUtils.h +33 -0
- package/ios/utils/StyleUtils.mm +290 -0
- package/ios/utils/TextBlockTapGestureRecognizer.h +17 -0
- package/ios/utils/TextBlockTapGestureRecognizer.mm +56 -0
- package/ios/utils/TextInsertionUtils.h +17 -0
- package/ios/utils/TextInsertionUtils.mm +60 -0
- package/ios/utils/TextListsUtils.h +40 -0
- package/ios/utils/TextListsUtils.mm +93 -0
- package/ios/utils/WeakBox.h +3 -0
- package/ios/utils/WeakBox.m +4 -0
- package/ios/utils/WordsUtils.h +7 -0
- package/ios/utils/WordsUtils.mm +98 -0
- package/ios/utils/ZeroWidthSpaceUtils.h +14 -0
- package/ios/utils/ZeroWidthSpaceUtils.mm +310 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/index.native.js +7 -0
- package/lib/module/index.native.js.map +1 -0
- package/lib/module/native/EnrichedText.js +76 -0
- package/lib/module/native/EnrichedText.js.map +1 -0
- package/lib/module/native/EnrichedTextInput.js +306 -0
- package/lib/module/native/EnrichedTextInput.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/spec/EnrichedTextInputNativeComponent.ts +524 -0
- package/lib/module/spec/EnrichedTextNativeComponent.ts +110 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/EnrichedTextInputDefaultProps.js +20 -0
- package/lib/module/utils/EnrichedTextInputDefaultProps.js.map +1 -0
- package/lib/module/utils/defaultHtmlStyle.js +83 -0
- package/lib/module/utils/defaultHtmlStyle.js.map +1 -0
- package/lib/module/utils/expandMentionStylesForIndicators.js +15 -0
- package/lib/module/utils/expandMentionStylesForIndicators.js.map +1 -0
- package/lib/module/utils/isMentionStyleRecord.js +10 -0
- package/lib/module/utils/isMentionStyleRecord.js.map +1 -0
- package/lib/module/utils/normalizeHtmlStyle.js +126 -0
- package/lib/module/utils/normalizeHtmlStyle.js.map +1 -0
- package/lib/module/utils/nullthrows.js +9 -0
- package/lib/module/utils/nullthrows.js.map +1 -0
- package/lib/module/utils/regexParser.js +46 -0
- package/lib/module/utils/regexParser.js.map +1 -0
- package/lib/module/web/EnrichedTextInput.css +201 -0
- package/lib/module/web/EnrichedTextInput.js +314 -0
- package/lib/module/web/EnrichedTextInput.js.map +1 -0
- package/lib/module/web/adaptWebToNativeEvent.js +34 -0
- package/lib/module/web/adaptWebToNativeEvent.js.map +1 -0
- package/lib/module/web/checkboxHtmlNormalizer.js +54 -0
- package/lib/module/web/checkboxHtmlNormalizer.js.map +1 -0
- package/lib/module/web/formats/EnrichedBlockquote.js +32 -0
- package/lib/module/web/formats/EnrichedBlockquote.js.map +1 -0
- package/lib/module/web/formats/EnrichedBold.js +22 -0
- package/lib/module/web/formats/EnrichedBold.js.map +1 -0
- package/lib/module/web/formats/EnrichedCheckboxItem.js +32 -0
- package/lib/module/web/formats/EnrichedCheckboxItem.js.map +1 -0
- package/lib/module/web/formats/EnrichedCheckboxList.js +35 -0
- package/lib/module/web/formats/EnrichedCheckboxList.js.map +1 -0
- package/lib/module/web/formats/EnrichedCode.js +15 -0
- package/lib/module/web/formats/EnrichedCode.js.map +1 -0
- package/lib/module/web/formats/EnrichedCodeBlock.js +43 -0
- package/lib/module/web/formats/EnrichedCodeBlock.js.map +1 -0
- package/lib/module/web/formats/EnrichedHeading.js +27 -0
- package/lib/module/web/formats/EnrichedHeading.js.map +1 -0
- package/lib/module/web/formats/EnrichedImage.js +57 -0
- package/lib/module/web/formats/EnrichedImage.js.map +1 -0
- package/lib/module/web/formats/EnrichedImageNodeView.js +90 -0
- package/lib/module/web/formats/EnrichedImageNodeView.js.map +1 -0
- package/lib/module/web/formats/EnrichedItalic.js +22 -0
- package/lib/module/web/formats/EnrichedItalic.js.map +1 -0
- package/lib/module/web/formats/EnrichedLink.js +140 -0
- package/lib/module/web/formats/EnrichedLink.js.map +1 -0
- package/lib/module/web/formats/EnrichedListItem.js +19 -0
- package/lib/module/web/formats/EnrichedListItem.js.map +1 -0
- package/lib/module/web/formats/EnrichedMention.js +50 -0
- package/lib/module/web/formats/EnrichedMention.js.map +1 -0
- package/lib/module/web/formats/EnrichedOrderedList.js +32 -0
- package/lib/module/web/formats/EnrichedOrderedList.js.map +1 -0
- package/lib/module/web/formats/EnrichedStrike.js +22 -0
- package/lib/module/web/formats/EnrichedStrike.js.map +1 -0
- package/lib/module/web/formats/EnrichedUnderline.js +22 -0
- package/lib/module/web/formats/EnrichedUnderline.js.map +1 -0
- package/lib/module/web/formats/EnrichedUnorderedList.js +33 -0
- package/lib/module/web/formats/EnrichedUnorderedList.js.map +1 -0
- package/lib/module/web/formats/applyWrappingListToSelection.js +63 -0
- package/lib/module/web/formats/applyWrappingListToSelection.js.map +1 -0
- package/lib/module/web/formats/formatRules.js +48 -0
- package/lib/module/web/formats/formatRules.js.map +1 -0
- package/lib/module/web/formats/listKeyboard.js +50 -0
- package/lib/module/web/formats/listKeyboard.js.map +1 -0
- package/lib/module/web/formats/wrappedBlockKeyboard.js +58 -0
- package/lib/module/web/formats/wrappedBlockKeyboard.js.map +1 -0
- package/lib/module/web/pasteImages.js +78 -0
- package/lib/module/web/pasteImages.js.map +1 -0
- package/lib/module/web/pastedImageDimensions.js +49 -0
- package/lib/module/web/pastedImageDimensions.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/index.js +36 -0
- package/lib/module/web/pmPlugins/MentionPlugin/index.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/isCaretInBlockedContext.js +11 -0
- package/lib/module/web/pmPlugins/MentionPlugin/isCaretInBlockedContext.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/makeMentionPluginState.js +67 -0
- package/lib/module/web/pmPlugins/MentionPlugin/makeMentionPluginState.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/mentionPluginKey.js +5 -0
- package/lib/module/web/pmPlugins/MentionPlugin/mentionPluginKey.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/removeMentionMarksIfSpansResized.js +56 -0
- package/lib/module/web/pmPlugins/MentionPlugin/removeMentionMarksIfSpansResized.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/setMention.js +58 -0
- package/lib/module/web/pmPlugins/MentionPlugin/setMention.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/startMention.js +9 -0
- package/lib/module/web/pmPlugins/MentionPlugin/startMention.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/stripPartialMentionMarks.js +9 -0
- package/lib/module/web/pmPlugins/MentionPlugin/stripPartialMentionMarks.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/subscribeMentionEvents.js +100 -0
- package/lib/module/web/pmPlugins/MentionPlugin/subscribeMentionEvents.js.map +1 -0
- package/lib/module/web/pmPlugins/MentionPlugin/types.js +4 -0
- package/lib/module/web/pmPlugins/MentionPlugin/types.js.map +1 -0
- package/lib/module/web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.js +42 -0
- package/lib/module/web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.js.map +1 -0
- package/lib/module/web/pmPlugins/ShortcutPlugin.js +123 -0
- package/lib/module/web/pmPlugins/ShortcutPlugin.js.map +1 -0
- package/lib/module/web/pmPlugins/StrictMarksPlugin.js +98 -0
- package/lib/module/web/pmPlugins/StrictMarksPlugin.js.map +1 -0
- package/lib/module/web/pmPlugins/StripBoldInStyledHeadingsPlugin.js +56 -0
- package/lib/module/web/pmPlugins/StripBoldInStyledHeadingsPlugin.js.map +1 -0
- package/lib/module/web/pmPlugins/StripMarksInCodeBlockPlugin.js +28 -0
- package/lib/module/web/pmPlugins/StripMarksInCodeBlockPlugin.js.map +1 -0
- package/lib/module/web/pmPlugins/StripMarksOnImagePlugin.js +29 -0
- package/lib/module/web/pmPlugins/StripMarksOnImagePlugin.js.map +1 -0
- package/lib/module/web/positionMapping.js +76 -0
- package/lib/module/web/positionMapping.js.map +1 -0
- package/lib/module/web/returnKeyTypeToEnterKeyHint.js +20 -0
- package/lib/module/web/returnKeyTypeToEnterKeyHint.js.map +1 -0
- package/lib/module/web/styleConversion/buildMentionRulesCSS.js +33 -0
- package/lib/module/web/styleConversion/buildMentionRulesCSS.js.map +1 -0
- package/lib/module/web/styleConversion/enrichedInputStyleToCSSProperties.js +159 -0
- package/lib/module/web/styleConversion/enrichedInputStyleToCSSProperties.js.map +1 -0
- package/lib/module/web/styleConversion/enrichedInputThemingToCSSProperties.js +18 -0
- package/lib/module/web/styleConversion/enrichedInputThemingToCSSProperties.js.map +1 -0
- package/lib/module/web/styleConversion/htmlStyleToCSSVariables.js +145 -0
- package/lib/module/web/styleConversion/htmlStyleToCSSVariables.js.map +1 -0
- package/lib/module/web/styleConversion/mentionIndicatorCssKey.js +15 -0
- package/lib/module/web/styleConversion/mentionIndicatorCssKey.js.map +1 -0
- package/lib/module/web/styleConversion/toColor.js +18 -0
- package/lib/module/web/styleConversion/toColor.js.map +1 -0
- package/lib/module/web/tiptapHtmlNormalizer.js +30 -0
- package/lib/module/web/tiptapHtmlNormalizer.js.map +1 -0
- package/lib/module/web/useOnChangeHtml.js +8 -0
- package/lib/module/web/useOnChangeHtml.js.map +1 -0
- package/lib/module/web/useOnChangeState.js +88 -0
- package/lib/module/web/useOnChangeState.js.map +1 -0
- package/lib/module/web/useOnChangeText.js +11 -0
- package/lib/module/web/useOnChangeText.js.map +1 -0
- package/lib/module/web/useOnEditorChange.js +25 -0
- package/lib/module/web/useOnEditorChange.js.map +1 -0
- package/lib/module/web/useOnLinkDetected.js +68 -0
- package/lib/module/web/useOnLinkDetected.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/index.native.d.ts +5 -0
- package/lib/typescript/src/index.native.d.ts.map +1 -0
- package/lib/typescript/src/native/EnrichedText.d.ts +3 -0
- package/lib/typescript/src/native/EnrichedText.d.ts.map +1 -0
- package/lib/typescript/src/native/EnrichedTextInput.d.ts +3 -0
- package/lib/typescript/src/native/EnrichedTextInput.d.ts.map +1 -0
- package/lib/typescript/src/spec/EnrichedTextInputNativeComponent.d.ts +405 -0
- package/lib/typescript/src/spec/EnrichedTextInputNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/spec/EnrichedTextNativeComponent.d.ts +88 -0
- package/lib/typescript/src/spec/EnrichedTextNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +721 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/EnrichedTextInputDefaultProps.d.ts +13 -0
- package/lib/typescript/src/utils/EnrichedTextInputDefaultProps.d.ts.map +1 -0
- package/lib/typescript/src/utils/defaultHtmlStyle.d.ts +4 -0
- package/lib/typescript/src/utils/defaultHtmlStyle.d.ts.map +1 -0
- package/lib/typescript/src/utils/expandMentionStylesForIndicators.d.ts +3 -0
- package/lib/typescript/src/utils/expandMentionStylesForIndicators.d.ts.map +1 -0
- package/lib/typescript/src/utils/isMentionStyleRecord.d.ts +3 -0
- package/lib/typescript/src/utils/isMentionStyleRecord.d.ts.map +1 -0
- package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts +6 -0
- package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts.map +1 -0
- package/lib/typescript/src/utils/nullthrows.d.ts +2 -0
- package/lib/typescript/src/utils/nullthrows.d.ts.map +1 -0
- package/lib/typescript/src/utils/regexParser.d.ts +3 -0
- package/lib/typescript/src/utils/regexParser.d.ts.map +1 -0
- package/lib/typescript/src/web/EnrichedTextInput.d.ts +4 -0
- package/lib/typescript/src/web/EnrichedTextInput.d.ts.map +1 -0
- package/lib/typescript/src/web/adaptWebToNativeEvent.d.ts +3 -0
- package/lib/typescript/src/web/adaptWebToNativeEvent.d.ts.map +1 -0
- package/lib/typescript/src/web/checkboxHtmlNormalizer.d.ts +3 -0
- package/lib/typescript/src/web/checkboxHtmlNormalizer.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedBlockquote.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedBlockquote.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedBold.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedBold.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedCheckboxItem.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedCheckboxItem.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedCheckboxList.d.ts +9 -0
- package/lib/typescript/src/web/formats/EnrichedCheckboxList.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedCode.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedCode.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedCodeBlock.d.ts +9 -0
- package/lib/typescript/src/web/formats/EnrichedCodeBlock.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedHeading.d.ts +5 -0
- package/lib/typescript/src/web/formats/EnrichedHeading.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedImage.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedImage.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedImageNodeView.d.ts +3 -0
- package/lib/typescript/src/web/formats/EnrichedImageNodeView.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedItalic.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedItalic.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedLink.d.ts +5 -0
- package/lib/typescript/src/web/formats/EnrichedLink.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedListItem.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedListItem.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedMention.d.ts +4 -0
- package/lib/typescript/src/web/formats/EnrichedMention.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedOrderedList.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedOrderedList.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedStrike.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedStrike.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedUnderline.d.ts +2 -0
- package/lib/typescript/src/web/formats/EnrichedUnderline.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/EnrichedUnorderedList.d.ts +9 -0
- package/lib/typescript/src/web/formats/EnrichedUnorderedList.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/applyWrappingListToSelection.d.ts +18 -0
- package/lib/typescript/src/web/formats/applyWrappingListToSelection.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/formatRules.d.ts +10 -0
- package/lib/typescript/src/web/formats/formatRules.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/listKeyboard.d.ts +4 -0
- package/lib/typescript/src/web/formats/listKeyboard.d.ts.map +1 -0
- package/lib/typescript/src/web/formats/wrappedBlockKeyboard.d.ts +12 -0
- package/lib/typescript/src/web/formats/wrappedBlockKeyboard.d.ts.map +1 -0
- package/lib/typescript/src/web/pasteImages.d.ts +10 -0
- package/lib/typescript/src/web/pasteImages.d.ts.map +1 -0
- package/lib/typescript/src/web/pastedImageDimensions.d.ts +9 -0
- package/lib/typescript/src/web/pastedImageDimensions.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/index.d.ts +9 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/index.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/isCaretInBlockedContext.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/isCaretInBlockedContext.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/makeMentionPluginState.d.ts +4 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/makeMentionPluginState.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/mentionPluginKey.d.ts +4 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/mentionPluginKey.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/removeMentionMarksIfSpansResized.d.ts +9 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/removeMentionMarksIfSpansResized.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/setMention.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/setMention.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/startMention.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/startMention.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/stripPartialMentionMarks.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/stripPartialMentionMarks.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.d.ts +4 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/types.d.ts +20 -0
- package/lib/typescript/src/web/pmPlugins/MentionPlugin/types.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/ShortcutPlugin.d.ts +7 -0
- package/lib/typescript/src/web/pmPlugins/ShortcutPlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/StrictMarksPlugin.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/StrictMarksPlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.d.ts +10 -0
- package/lib/typescript/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/StripMarksInCodeBlockPlugin.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/StripMarksInCodeBlockPlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/pmPlugins/StripMarksOnImagePlugin.d.ts +3 -0
- package/lib/typescript/src/web/pmPlugins/StripMarksOnImagePlugin.d.ts.map +1 -0
- package/lib/typescript/src/web/positionMapping.d.ts +39 -0
- package/lib/typescript/src/web/positionMapping.d.ts.map +1 -0
- package/lib/typescript/src/web/returnKeyTypeToEnterKeyHint.d.ts +4 -0
- package/lib/typescript/src/web/returnKeyTypeToEnterKeyHint.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/buildMentionRulesCSS.d.ts +3 -0
- package/lib/typescript/src/web/styleConversion/buildMentionRulesCSS.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/enrichedInputStyleToCSSProperties.d.ts +8 -0
- package/lib/typescript/src/web/styleConversion/enrichedInputStyleToCSSProperties.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/enrichedInputThemingToCSSProperties.d.ts +9 -0
- package/lib/typescript/src/web/styleConversion/enrichedInputThemingToCSSProperties.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/htmlStyleToCSSVariables.d.ts +10 -0
- package/lib/typescript/src/web/styleConversion/htmlStyleToCSSVariables.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/mentionIndicatorCssKey.d.ts +3 -0
- package/lib/typescript/src/web/styleConversion/mentionIndicatorCssKey.d.ts.map +1 -0
- package/lib/typescript/src/web/styleConversion/toColor.d.ts +3 -0
- package/lib/typescript/src/web/styleConversion/toColor.d.ts.map +1 -0
- package/lib/typescript/src/web/tiptapHtmlNormalizer.d.ts +3 -0
- package/lib/typescript/src/web/tiptapHtmlNormalizer.d.ts.map +1 -0
- package/lib/typescript/src/web/useOnChangeHtml.d.ts +5 -0
- package/lib/typescript/src/web/useOnChangeHtml.d.ts.map +1 -0
- package/lib/typescript/src/web/useOnChangeState.d.ts +6 -0
- package/lib/typescript/src/web/useOnChangeState.d.ts.map +1 -0
- package/lib/typescript/src/web/useOnChangeText.d.ts +5 -0
- package/lib/typescript/src/web/useOnChangeText.d.ts.map +1 -0
- package/lib/typescript/src/web/useOnEditorChange.d.ts +6 -0
- package/lib/typescript/src/web/useOnEditorChange.d.ts.map +1 -0
- package/lib/typescript/src/web/useOnLinkDetected.d.ts +4 -0
- package/lib/typescript/src/web/useOnLinkDetected.d.ts.map +1 -0
- package/package.json +232 -1
- package/react-native.config.js +16 -0
- package/src/index.native.tsx +34 -0
- package/src/index.tsx +24 -0
- package/src/native/EnrichedText.tsx +115 -0
- package/src/native/EnrichedTextInput.tsx +374 -0
- package/src/spec/EnrichedTextInputNativeComponent.ts +524 -0
- package/src/spec/EnrichedTextNativeComponent.ts +110 -0
- package/src/types.ts +864 -0
- package/src/utils/EnrichedTextInputDefaultProps.ts +16 -0
- package/src/utils/defaultHtmlStyle.ts +83 -0
- package/src/utils/expandMentionStylesForIndicators.ts +19 -0
- package/src/utils/isMentionStyleRecord.ts +22 -0
- package/src/utils/normalizeHtmlStyle.ts +181 -0
- package/src/utils/nullthrows.ts +7 -0
- package/src/utils/regexParser.ts +56 -0
- package/src/web/EnrichedTextInput.css +201 -0
- package/src/web/EnrichedTextInput.tsx +403 -0
- package/src/web/adaptWebToNativeEvent.ts +37 -0
- package/src/web/checkboxHtmlNormalizer.ts +62 -0
- package/src/web/formats/EnrichedBlockquote.ts +36 -0
- package/src/web/formats/EnrichedBold.ts +16 -0
- package/src/web/formats/EnrichedCheckboxItem.ts +35 -0
- package/src/web/formats/EnrichedCheckboxList.ts +47 -0
- package/src/web/formats/EnrichedCode.ts +13 -0
- package/src/web/formats/EnrichedCodeBlock.ts +53 -0
- package/src/web/formats/EnrichedHeading.ts +36 -0
- package/src/web/formats/EnrichedImage.ts +59 -0
- package/src/web/formats/EnrichedImageNodeView.tsx +89 -0
- package/src/web/formats/EnrichedItalic.ts +16 -0
- package/src/web/formats/EnrichedLink.ts +149 -0
- package/src/web/formats/EnrichedListItem.ts +17 -0
- package/src/web/formats/EnrichedMention.ts +55 -0
- package/src/web/formats/EnrichedOrderedList.ts +40 -0
- package/src/web/formats/EnrichedStrike.ts +16 -0
- package/src/web/formats/EnrichedUnderline.ts +16 -0
- package/src/web/formats/EnrichedUnorderedList.ts +50 -0
- package/src/web/formats/applyWrappingListToSelection.ts +76 -0
- package/src/web/formats/formatRules.ts +84 -0
- package/src/web/formats/listKeyboard.ts +58 -0
- package/src/web/formats/wrappedBlockKeyboard.ts +76 -0
- package/src/web/pasteImages.ts +96 -0
- package/src/web/pastedImageDimensions.ts +40 -0
- package/src/web/pmPlugins/MentionPlugin/index.ts +45 -0
- package/src/web/pmPlugins/MentionPlugin/isCaretInBlockedContext.ts +17 -0
- package/src/web/pmPlugins/MentionPlugin/makeMentionPluginState.ts +75 -0
- package/src/web/pmPlugins/MentionPlugin/mentionPluginKey.ts +4 -0
- package/src/web/pmPlugins/MentionPlugin/removeMentionMarksIfSpansResized.ts +68 -0
- package/src/web/pmPlugins/MentionPlugin/setMention.ts +83 -0
- package/src/web/pmPlugins/MentionPlugin/startMention.ts +14 -0
- package/src/web/pmPlugins/MentionPlugin/stripPartialMentionMarks.ts +20 -0
- package/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.ts +105 -0
- package/src/web/pmPlugins/MentionPlugin/types.ts +22 -0
- package/src/web/pmPlugins/MergeAdjacentSameKindBlocksPlugin.ts +57 -0
- package/src/web/pmPlugins/ShortcutPlugin.ts +98 -0
- package/src/web/pmPlugins/StrictMarksPlugin.ts +131 -0
- package/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.ts +79 -0
- package/src/web/pmPlugins/StripMarksInCodeBlockPlugin.ts +34 -0
- package/src/web/pmPlugins/StripMarksOnImagePlugin.ts +33 -0
- package/src/web/positionMapping.ts +81 -0
- package/src/web/returnKeyTypeToEnterKeyHint.ts +29 -0
- package/src/web/styleConversion/buildMentionRulesCSS.ts +42 -0
- package/src/web/styleConversion/enrichedInputStyleToCSSProperties.ts +224 -0
- package/src/web/styleConversion/enrichedInputThemingToCSSProperties.ts +34 -0
- package/src/web/styleConversion/htmlStyleToCSSVariables.ts +226 -0
- package/src/web/styleConversion/mentionIndicatorCssKey.ts +14 -0
- package/src/web/styleConversion/toColor.ts +17 -0
- package/src/web/tiptapHtmlNormalizer.ts +33 -0
- package/src/web/useOnChangeHtml.ts +14 -0
- package/src/web/useOnChangeState.ts +125 -0
- package/src/web/useOnChangeText.ts +15 -0
- package/src/web/useOnEditorChange.ts +33 -0
- package/src/web/useOnLinkDetected.ts +82 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#import "TextHtmlParser.h"
|
|
2
|
+
#import "AlignmentEntry.h"
|
|
3
|
+
#import "EnrichedTextView.h"
|
|
4
|
+
#import "HtmlParser.h"
|
|
5
|
+
#import "LinkData.h"
|
|
6
|
+
#import "MentionParams.h"
|
|
7
|
+
#import "StyleHeaders.h"
|
|
8
|
+
#import "StyleUtils.h"
|
|
9
|
+
#import "ZeroWidthSpaceUtils.h"
|
|
10
|
+
#import <React/RCTLog.h>
|
|
11
|
+
|
|
12
|
+
@implementation TextHtmlParser
|
|
13
|
+
|
|
14
|
+
- (instancetype)initWithView:(EnrichedTextView *)view {
|
|
15
|
+
self = [super init];
|
|
16
|
+
_view = view;
|
|
17
|
+
return self;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
- (void)replaceWholeFromHtml:(NSString *_Nonnull)html {
|
|
21
|
+
@try {
|
|
22
|
+
NSString *normalized =
|
|
23
|
+
[HtmlParser initiallyProcessHtml:html
|
|
24
|
+
useHtmlNormalizer:_view->useHtmlNormalizer];
|
|
25
|
+
if (normalized == nil) {
|
|
26
|
+
[_view->textView.textStorage
|
|
27
|
+
setAttributedString:[[NSAttributedString alloc]
|
|
28
|
+
initWithString:html
|
|
29
|
+
attributes:_view->
|
|
30
|
+
defaultTypingAttributes]];
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
NSArray *result = [HtmlParser getTextAndStylesFromHtml:normalized];
|
|
35
|
+
NSString *plainText = result[0];
|
|
36
|
+
NSArray *processedStyles = result[1];
|
|
37
|
+
NSArray *alignments = result[2];
|
|
38
|
+
|
|
39
|
+
NSMutableAttributedString *body = [[NSMutableAttributedString alloc]
|
|
40
|
+
initWithString:plainText
|
|
41
|
+
attributes:_view->defaultTypingAttributes];
|
|
42
|
+
[_view->textView.textStorage setAttributedString:body];
|
|
43
|
+
[self applyProcessedStyles:processedStyles];
|
|
44
|
+
[self applyProcessedAlignments:alignments];
|
|
45
|
+
} @catch (NSException *exception) {
|
|
46
|
+
RCTLogWarn(@"[EnrichedTextView]: Failed to parse HTML: (%@), falling back "
|
|
47
|
+
@"to raw input.",
|
|
48
|
+
exception.reason);
|
|
49
|
+
[_view->textView.textStorage
|
|
50
|
+
setAttributedString:[[NSAttributedString alloc]
|
|
51
|
+
initWithString:html
|
|
52
|
+
attributes:_view->defaultTypingAttributes]];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
- (void)applyProcessedStyles:(NSArray *_Nonnull)processedStyles {
|
|
57
|
+
// Some paragraph styles (codeblock, blockquote, etc.) insert \u200B
|
|
58
|
+
// into empty lines, mutating NSTextStorage length. We need to
|
|
59
|
+
// shift subsequent ranges by this offset.
|
|
60
|
+
NSInteger zeroWidthSpaceOffset = 0;
|
|
61
|
+
|
|
62
|
+
// Inline styles collected during the first pass so their applyStyling: can
|
|
63
|
+
// be re-run after all paragraph styles have applied their visual attributes.
|
|
64
|
+
// Each entry is @[style, adjustedRange].
|
|
65
|
+
NSMutableArray *pendingInlineApply = [NSMutableArray array];
|
|
66
|
+
|
|
67
|
+
// Paragraph styles call applyStyling: immediately; inline styles
|
|
68
|
+
// defer it so that paragraph visual attributes are already in
|
|
69
|
+
// place when inline styles override them.
|
|
70
|
+
for (NSArray *arr in processedStyles) {
|
|
71
|
+
NSNumber *styleType = (NSNumber *)arr[0];
|
|
72
|
+
StylePair *stylePair = (StylePair *)arr[1];
|
|
73
|
+
StyleBase *style = _view->stylesDict[styleType];
|
|
74
|
+
if (style == nullptr)
|
|
75
|
+
continue;
|
|
76
|
+
|
|
77
|
+
NSRange parsedRange = [stylePair.rangeValue rangeValue];
|
|
78
|
+
NSUInteger textLengthBeforeStyleApplied =
|
|
79
|
+
_view->textView.textStorage.string.length;
|
|
80
|
+
|
|
81
|
+
// Range must be taking zeroWidthSpaceOffset into consideration
|
|
82
|
+
// because processed styles ranges are relative to only the new text while
|
|
83
|
+
// we need absolute ranges relative to the whole existing text
|
|
84
|
+
NSRange styleRange = NSMakeRange(
|
|
85
|
+
zeroWidthSpaceOffset + parsedRange.location, parsedRange.length);
|
|
86
|
+
|
|
87
|
+
if (![StyleUtils handleStyleBlocksAndConflicts:[[style class] getType]
|
|
88
|
+
range:styleRange
|
|
89
|
+
forHost:_view]) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if ([styleType isEqualToNumber:@([LinkStyle getType])]) {
|
|
94
|
+
LinkData *linkData = (LinkData *)stylePair.styleValue;
|
|
95
|
+
[((LinkStyle *)style) applyLinkMetaWithData:linkData range:styleRange];
|
|
96
|
+
} else if ([styleType isEqualToNumber:@([MentionStyle getType])]) {
|
|
97
|
+
MentionParams *params = (MentionParams *)stylePair.styleValue;
|
|
98
|
+
[((MentionStyle *)style) applyMentionMeta:params range:styleRange];
|
|
99
|
+
} else if ([styleType isEqualToNumber:@([ImageStyle getType])]) {
|
|
100
|
+
ImageData *imgData = (ImageData *)stylePair.styleValue;
|
|
101
|
+
[((ImageStyle *)style) addImageAtRange:styleRange
|
|
102
|
+
imageData:imgData
|
|
103
|
+
withSelection:NO
|
|
104
|
+
withDirtyRange:NO];
|
|
105
|
+
} else if ([styleType isEqualToNumber:@([CheckboxListStyle getType])]) {
|
|
106
|
+
NSDictionary *checkboxStates = (NSDictionary *)stylePair.styleValue;
|
|
107
|
+
CheckboxListStyle *cbStyle = (CheckboxListStyle *)style;
|
|
108
|
+
|
|
109
|
+
[cbStyle addWithChecked:NO
|
|
110
|
+
range:styleRange
|
|
111
|
+
withTyping:NO
|
|
112
|
+
withDirtyRange:NO];
|
|
113
|
+
|
|
114
|
+
if (checkboxStates && checkboxStates.count > 0) {
|
|
115
|
+
for (NSNumber *key in checkboxStates) {
|
|
116
|
+
NSUInteger checkboxPosition =
|
|
117
|
+
zeroWidthSpaceOffset + [key unsignedIntegerValue];
|
|
118
|
+
BOOL isChecked = [checkboxStates[key] boolValue];
|
|
119
|
+
|
|
120
|
+
if (isChecked) {
|
|
121
|
+
[cbStyle toggleCheckedAt:checkboxPosition withDirtyRange:NO];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
[style add:styleRange withTyping:NO withDirtyRange:NO];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
[ZeroWidthSpaceUtils addSpacesIfNeededInHost:_view inRange:styleRange];
|
|
130
|
+
|
|
131
|
+
NSInteger delta = _view->textView.textStorage.string.length -
|
|
132
|
+
textLengthBeforeStyleApplied;
|
|
133
|
+
|
|
134
|
+
// Use an adjusted range so that applyStyling covers any ZWS characters that
|
|
135
|
+
// were just inserted by addSpacesIfNeededInHost:inRange:. Without this, a
|
|
136
|
+
// style applied to an empty range {0,0} would call applyStyling on {0,0}
|
|
137
|
+
// even after a ZWS was inserted.
|
|
138
|
+
NSRange adjustedStyleRange = NSMakeRange(
|
|
139
|
+
styleRange.location, styleRange.length + (NSUInteger)MAX(0LL, delta));
|
|
140
|
+
|
|
141
|
+
if ([style isParagraph]) {
|
|
142
|
+
[style applyStyling:adjustedStyleRange];
|
|
143
|
+
} else {
|
|
144
|
+
[pendingInlineApply
|
|
145
|
+
addObject:@[ style, [NSValue valueWithRange:adjustedStyleRange] ]];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Image shifts are already handled by _precedingImageCount during tag
|
|
149
|
+
// finalization.
|
|
150
|
+
if (delta != 0 && ![styleType isEqualToNumber:@([ImageStyle getType])]) {
|
|
151
|
+
zeroWidthSpaceOffset += delta;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Apply visual styling for inline styles
|
|
156
|
+
for (NSArray *entry in pendingInlineApply) {
|
|
157
|
+
StyleBase *style = entry[0];
|
|
158
|
+
NSRange adjustedStyleRange = [((NSValue *)entry[1]) rangeValue];
|
|
159
|
+
[style applyStyling:adjustedStyleRange];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
- (void)applyProcessedAlignments:(NSArray<AlignmentEntry *> *)alignments {
|
|
164
|
+
AlignmentStyle *alignmentStyle =
|
|
165
|
+
_view.stylesDict[@([AlignmentStyle getType])];
|
|
166
|
+
|
|
167
|
+
if (alignmentStyle == nil) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
for (AlignmentEntry *entry in alignments) {
|
|
172
|
+
NSRange finalRange = NSMakeRange(entry.range.location, entry.range.length);
|
|
173
|
+
[alignmentStyle addAlignment:entry.alignment
|
|
174
|
+
range:finalRange
|
|
175
|
+
withTyping:NO
|
|
176
|
+
withDirtyRange:NO];
|
|
177
|
+
[alignmentStyle applyStyling:finalRange];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#import "AlignmentEntry.h"
|
|
2
|
+
#import "EnrichedTextInputView.h"
|
|
3
|
+
#import "StyleHeaders.h"
|
|
4
|
+
#import <UIKit/UIKit.h>
|
|
5
|
+
|
|
6
|
+
@interface AlignmentUtils : NSObject
|
|
7
|
+
|
|
8
|
+
+ (NSString *)alignmentToString:(NSTextAlignment)alignmentl;
|
|
9
|
+
|
|
10
|
+
+ (NSTextAlignment)stringToAlignment:(NSString *)alignmentString;
|
|
11
|
+
|
|
12
|
+
+ (NSString *)alignmentToMarker:(NSTextAlignment)alignment;
|
|
13
|
+
|
|
14
|
+
+ (NSTextAlignment)markerToAlignment:(NSString *)marker;
|
|
15
|
+
|
|
16
|
+
+ (NSString *)cssValueForAlignment:(NSTextAlignment)alignment;
|
|
17
|
+
|
|
18
|
+
+ (NSTextAlignment)alignmentFromStyleParams:(NSString *)params;
|
|
19
|
+
|
|
20
|
+
@end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#import "AlignmentUtils.h"
|
|
2
|
+
#import "RangeUtils.h"
|
|
3
|
+
#import "StyleHeaders.h"
|
|
4
|
+
|
|
5
|
+
@implementation AlignmentUtils
|
|
6
|
+
|
|
7
|
+
+ (NSString *)alignmentToString:(NSTextAlignment)alignment {
|
|
8
|
+
switch (alignment) {
|
|
9
|
+
case NSTextAlignmentLeft:
|
|
10
|
+
return @"left";
|
|
11
|
+
case NSTextAlignmentCenter:
|
|
12
|
+
return @"center";
|
|
13
|
+
case NSTextAlignmentRight:
|
|
14
|
+
return @"right";
|
|
15
|
+
case NSTextAlignmentJustified:
|
|
16
|
+
return @"justify";
|
|
17
|
+
case NSTextAlignmentNatural:
|
|
18
|
+
default:
|
|
19
|
+
return @"auto";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
+ (NSTextAlignment)stringToAlignment:(NSString *)alignmentString {
|
|
24
|
+
NSString *normalized = [alignmentString lowercaseString];
|
|
25
|
+
|
|
26
|
+
if ([normalized isEqualToString:@"left"]) {
|
|
27
|
+
return NSTextAlignmentLeft;
|
|
28
|
+
}
|
|
29
|
+
if ([normalized isEqualToString:@"center"]) {
|
|
30
|
+
return NSTextAlignmentCenter;
|
|
31
|
+
}
|
|
32
|
+
if ([normalized isEqualToString:@"right"]) {
|
|
33
|
+
return NSTextAlignmentRight;
|
|
34
|
+
}
|
|
35
|
+
if ([normalized isEqualToString:@"justify"]) {
|
|
36
|
+
return NSTextAlignmentJustified;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return NSTextAlignmentNatural;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
+ (NSTextAlignment)markerToAlignment:(NSString *)marker {
|
|
43
|
+
if ([marker isEqualToString:@"EnrichedAlignmentLeft"]) {
|
|
44
|
+
return NSTextAlignmentLeft;
|
|
45
|
+
} else if ([marker isEqualToString:@"EnrichedAlignmentCenter"]) {
|
|
46
|
+
return NSTextAlignmentCenter;
|
|
47
|
+
} else if ([marker isEqualToString:@"EnrichedAlignmentRight"]) {
|
|
48
|
+
return NSTextAlignmentRight;
|
|
49
|
+
} else if ([marker isEqualToString:@"EnrichedAlignmentJustified"]) {
|
|
50
|
+
return NSTextAlignmentJustified;
|
|
51
|
+
}
|
|
52
|
+
return NSTextAlignmentNatural;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
+ (NSString *)alignmentToMarker:(NSTextAlignment)alignment {
|
|
56
|
+
if (alignment == NSTextAlignmentLeft) {
|
|
57
|
+
return @"EnrichedAlignmentLeft";
|
|
58
|
+
} else if (alignment == NSTextAlignmentCenter) {
|
|
59
|
+
return @"EnrichedAlignmentCenter";
|
|
60
|
+
} else if (alignment == NSTextAlignmentRight) {
|
|
61
|
+
return @"EnrichedAlignmentRight";
|
|
62
|
+
} else if (alignment == NSTextAlignmentJustified) {
|
|
63
|
+
return @"EnrichedAlignmentJustified";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return @"EnrichedAlignmentNatural";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
+ (NSString *)cssValueForAlignment:(NSTextAlignment)alignment {
|
|
70
|
+
switch (alignment) {
|
|
71
|
+
case NSTextAlignmentLeft:
|
|
72
|
+
return @"left";
|
|
73
|
+
case NSTextAlignmentCenter:
|
|
74
|
+
return @"center";
|
|
75
|
+
case NSTextAlignmentRight:
|
|
76
|
+
return @"right";
|
|
77
|
+
case NSTextAlignmentJustified:
|
|
78
|
+
return @"justify";
|
|
79
|
+
default:
|
|
80
|
+
return nil;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
+ (NSTextAlignment)alignmentFromStyleParams:(NSString *)params {
|
|
85
|
+
if (!params)
|
|
86
|
+
return NSTextAlignmentNatural;
|
|
87
|
+
|
|
88
|
+
NSString *pattern = @"text-align\\s*:\\s*(left|center|right|justify)";
|
|
89
|
+
|
|
90
|
+
NSRegularExpression *regex = [NSRegularExpression
|
|
91
|
+
regularExpressionWithPattern:pattern
|
|
92
|
+
options:NSRegularExpressionCaseInsensitive
|
|
93
|
+
error:nil];
|
|
94
|
+
|
|
95
|
+
NSTextCheckingResult *match =
|
|
96
|
+
[regex firstMatchInString:params
|
|
97
|
+
options:0
|
|
98
|
+
range:NSMakeRange(0, params.length)];
|
|
99
|
+
|
|
100
|
+
if (match) {
|
|
101
|
+
// rangeAtIndex:1 corresponds to the capture group
|
|
102
|
+
// (left|center|right|justify)
|
|
103
|
+
NSString *value =
|
|
104
|
+
[[params substringWithRange:[match rangeAtIndex:1]] lowercaseString];
|
|
105
|
+
return [AlignmentUtils stringToAlignment:value];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return NSTextAlignmentNatural;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#import "EnrichedConfig.h"
|
|
3
|
+
#import "ImageAttachment.h"
|
|
4
|
+
#import <UIKit/UIKit.h>
|
|
5
|
+
|
|
6
|
+
@interface AttachmentLayoutUtils : NSObject
|
|
7
|
+
|
|
8
|
+
+ (void)handleAttachmentUpdate:(MediaAttachment *)attachment
|
|
9
|
+
textView:(UITextView *)textView
|
|
10
|
+
onLayoutBlock:(dispatch_block_t)layoutBlock;
|
|
11
|
+
|
|
12
|
+
+ (NSMutableDictionary<NSValue *, UIImageView *> *)
|
|
13
|
+
layoutAttachmentsInTextView:(UITextView *)textView
|
|
14
|
+
config:(EnrichedConfig *)config
|
|
15
|
+
existingViews:
|
|
16
|
+
(NSMutableDictionary<NSValue *, UIImageView *> *)
|
|
17
|
+
attachmentViews;
|
|
18
|
+
|
|
19
|
+
+ (CGRect)frameForAttachment:(ImageAttachment *)attachment
|
|
20
|
+
atRange:(NSRange)range
|
|
21
|
+
textView:(UITextView *)textView
|
|
22
|
+
config:(EnrichedConfig *)config;
|
|
23
|
+
|
|
24
|
+
@end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#import "AttachmentLayoutUtils.h"
|
|
2
|
+
|
|
3
|
+
@implementation AttachmentLayoutUtils
|
|
4
|
+
|
|
5
|
+
+ (void)handleAttachmentUpdate:(MediaAttachment *)attachment
|
|
6
|
+
textView:(UITextView *)textView
|
|
7
|
+
onLayoutBlock:(dispatch_block_t)layoutBlock {
|
|
8
|
+
NSTextStorage *storage = textView.textStorage;
|
|
9
|
+
NSRange fullRange = NSMakeRange(0, storage.length);
|
|
10
|
+
|
|
11
|
+
__block NSRange foundRange = NSMakeRange(NSNotFound, 0);
|
|
12
|
+
|
|
13
|
+
[storage enumerateAttribute:NSAttachmentAttributeName
|
|
14
|
+
inRange:fullRange
|
|
15
|
+
options:0
|
|
16
|
+
usingBlock:^(id value, NSRange range, BOOL *stop) {
|
|
17
|
+
if (value == attachment) {
|
|
18
|
+
foundRange = range;
|
|
19
|
+
*stop = YES;
|
|
20
|
+
}
|
|
21
|
+
}];
|
|
22
|
+
|
|
23
|
+
if (foundRange.location == NSNotFound) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[storage edited:NSTextStorageEditedAttributes
|
|
28
|
+
range:foundRange
|
|
29
|
+
changeInLength:0];
|
|
30
|
+
|
|
31
|
+
dispatch_async(dispatch_get_main_queue(), layoutBlock);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
+ (NSMutableDictionary<NSValue *, UIImageView *> *)
|
|
35
|
+
layoutAttachmentsInTextView:(UITextView *)textView
|
|
36
|
+
config:(EnrichedConfig *)config
|
|
37
|
+
existingViews:
|
|
38
|
+
(NSMutableDictionary<NSValue *, UIImageView *> *)
|
|
39
|
+
attachmentViews {
|
|
40
|
+
NSTextStorage *storage = textView.textStorage;
|
|
41
|
+
NSMutableDictionary<NSValue *, UIImageView *> *activeAttachmentViews =
|
|
42
|
+
[NSMutableDictionary dictionary];
|
|
43
|
+
|
|
44
|
+
if (storage.length > 0) {
|
|
45
|
+
// Iterate over the entire text to find ImageAttachments
|
|
46
|
+
[storage enumerateAttribute:NSAttachmentAttributeName
|
|
47
|
+
inRange:NSMakeRange(0, storage.length)
|
|
48
|
+
options:0
|
|
49
|
+
usingBlock:^(id value, NSRange range, BOOL *stop) {
|
|
50
|
+
if ([value isKindOfClass:[ImageAttachment class]]) {
|
|
51
|
+
ImageAttachment *attachment = (ImageAttachment *)value;
|
|
52
|
+
|
|
53
|
+
CGRect rect = [self frameForAttachment:attachment
|
|
54
|
+
atRange:range
|
|
55
|
+
textView:textView
|
|
56
|
+
config:config];
|
|
57
|
+
|
|
58
|
+
// Get or Create the UIImageView for this specific
|
|
59
|
+
// attachment key
|
|
60
|
+
NSValue *key =
|
|
61
|
+
[NSValue valueWithNonretainedObject:attachment];
|
|
62
|
+
UIImageView *imgView = attachmentViews[key];
|
|
63
|
+
|
|
64
|
+
if (!imgView) {
|
|
65
|
+
// It doesn't exist yet, create it
|
|
66
|
+
imgView = [[UIImageView alloc] initWithFrame:rect];
|
|
67
|
+
imgView.contentMode =
|
|
68
|
+
UIViewContentModeScaleAspectFit;
|
|
69
|
+
imgView.tintColor = [UIColor labelColor];
|
|
70
|
+
|
|
71
|
+
// Add it directly to the TextView
|
|
72
|
+
[textView addSubview:imgView];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Update position (in case text moved/scrolled)
|
|
76
|
+
if (!CGRectEqualToRect(imgView.frame, rect)) {
|
|
77
|
+
imgView.frame = rect;
|
|
78
|
+
}
|
|
79
|
+
UIImage *targetImage =
|
|
80
|
+
attachment.storedAnimatedImage ?: attachment.image;
|
|
81
|
+
|
|
82
|
+
// Only set if different to avoid resetting the
|
|
83
|
+
// animation loop
|
|
84
|
+
if (imgView.image != targetImage) {
|
|
85
|
+
imgView.image = targetImage;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Ensure it is visible on top
|
|
89
|
+
imgView.hidden = NO;
|
|
90
|
+
[textView bringSubviewToFront:imgView];
|
|
91
|
+
|
|
92
|
+
activeAttachmentViews[key] = imgView;
|
|
93
|
+
// Remove from the old map so we know it has been
|
|
94
|
+
// claimed
|
|
95
|
+
[attachmentViews removeObjectForKey:key];
|
|
96
|
+
}
|
|
97
|
+
}];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Everything remaining in attachmentViews is dead or off-screen
|
|
101
|
+
for (UIImageView *danglingView in attachmentViews.allValues) {
|
|
102
|
+
[danglingView removeFromSuperview];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return activeAttachmentViews;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
+ (CGRect)frameForAttachment:(ImageAttachment *)attachment
|
|
109
|
+
atRange:(NSRange)range
|
|
110
|
+
textView:(UITextView *)textView
|
|
111
|
+
config:(EnrichedConfig *)config {
|
|
112
|
+
NSLayoutManager *layoutManager = textView.layoutManager;
|
|
113
|
+
NSTextContainer *textContainer = textView.textContainer;
|
|
114
|
+
NSTextStorage *storage = textView.textStorage;
|
|
115
|
+
|
|
116
|
+
NSRange glyphRange = [layoutManager glyphRangeForCharacterRange:range
|
|
117
|
+
actualCharacterRange:NULL];
|
|
118
|
+
CGRect glyphRect = [layoutManager boundingRectForGlyphRange:glyphRange
|
|
119
|
+
inTextContainer:textContainer];
|
|
120
|
+
|
|
121
|
+
CGRect lineRect =
|
|
122
|
+
[layoutManager lineFragmentRectForGlyphAtIndex:glyphRange.location
|
|
123
|
+
effectiveRange:NULL];
|
|
124
|
+
CGSize attachmentSize = attachment.bounds.size;
|
|
125
|
+
|
|
126
|
+
UIFont *font = [storage attribute:NSFontAttributeName
|
|
127
|
+
atIndex:range.location
|
|
128
|
+
effectiveRange:NULL];
|
|
129
|
+
if (!font) {
|
|
130
|
+
font = [config primaryFont];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Calculate (Baseline Alignment)
|
|
134
|
+
CGFloat targetY =
|
|
135
|
+
CGRectGetMaxY(lineRect) + font.descender - attachmentSize.height;
|
|
136
|
+
CGRect rect =
|
|
137
|
+
CGRectMake(glyphRect.origin.x + textView.textContainerInset.left,
|
|
138
|
+
targetY + textView.textContainerInset.top,
|
|
139
|
+
attachmentSize.width, attachmentSize.height);
|
|
140
|
+
|
|
141
|
+
return CGRectIntegral(rect);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#import "CheckboxHitTestUtils.h"
|
|
2
|
+
#import "EnrichedConfig.h"
|
|
3
|
+
#import "EnrichedTextInputView.h"
|
|
4
|
+
#import "StyleHeaders.h"
|
|
5
|
+
|
|
6
|
+
static const CGFloat kCheckboxHitSlopLeft = 8.0;
|
|
7
|
+
static const CGFloat kCheckboxHitSlopVertical = 6.0;
|
|
8
|
+
|
|
9
|
+
@implementation CheckboxHitTestUtils
|
|
10
|
+
|
|
11
|
+
// MARK: - Coordinate helpers
|
|
12
|
+
|
|
13
|
+
+ (CGPoint)containerPointFromViewPoint:(CGPoint)point
|
|
14
|
+
textView:(UITextView *)textView {
|
|
15
|
+
return CGPointMake(point.x - textView.textContainerInset.left,
|
|
16
|
+
point.y - textView.textContainerInset.top);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// MARK: - Glyph lookup
|
|
20
|
+
|
|
21
|
+
+ (NSUInteger)glyphIndexAtContainerPoint:(CGPoint)point
|
|
22
|
+
textView:(UITextView *)textView {
|
|
23
|
+
return [textView.layoutManager glyphIndexForPoint:point
|
|
24
|
+
inTextContainer:textView.textContainer
|
|
25
|
+
fractionOfDistanceThroughGlyph:nil];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// MARK: - Checkbox detection
|
|
29
|
+
|
|
30
|
+
+ (BOOL)isCheckboxGlyph:(NSUInteger)glyphIndex
|
|
31
|
+
inInput:(EnrichedTextInputView *)input {
|
|
32
|
+
UITextView *textView = input->textView;
|
|
33
|
+
NSLayoutManager *layoutManager = textView.layoutManager;
|
|
34
|
+
NSTextStorage *storage = textView.textStorage;
|
|
35
|
+
|
|
36
|
+
NSUInteger charIndex =
|
|
37
|
+
[layoutManager characterIndexForGlyphAtIndex:glyphIndex];
|
|
38
|
+
|
|
39
|
+
if (charIndex >= storage.length) {
|
|
40
|
+
return NO;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
CheckboxListStyle *checkboxListStyle =
|
|
44
|
+
(CheckboxListStyle *)input->stylesDict[@([CheckboxListStyle getType])];
|
|
45
|
+
|
|
46
|
+
if (!checkboxListStyle) {
|
|
47
|
+
return NO;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return [checkboxListStyle detect:NSMakeRange(charIndex, 0)];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// MARK: - Checkbox rect
|
|
54
|
+
|
|
55
|
+
+ (CGRect)checkboxRectForGlyphIndex:(NSUInteger)glyphIndex
|
|
56
|
+
inInput:(EnrichedTextInputView *)input {
|
|
57
|
+
UITextView *textView = input->textView;
|
|
58
|
+
NSLayoutManager *layoutManager = textView.layoutManager;
|
|
59
|
+
EnrichedConfig *config = input->config;
|
|
60
|
+
|
|
61
|
+
if (!config) {
|
|
62
|
+
return CGRectNull;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
CGRect lineRect = [layoutManager lineFragmentRectForGlyphAtIndex:glyphIndex
|
|
66
|
+
effectiveRange:nil];
|
|
67
|
+
|
|
68
|
+
CGFloat originX = lineRect.origin.x + config.checkboxListMarginLeft;
|
|
69
|
+
|
|
70
|
+
CGFloat originY = lineRect.origin.y +
|
|
71
|
+
(lineRect.size.height - config.checkboxListBoxSize) / 2.0;
|
|
72
|
+
|
|
73
|
+
return CGRectMake(originX, originY, config.checkboxListBoxSize,
|
|
74
|
+
config.checkboxListBoxSize);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// MARK: - Hit rect
|
|
78
|
+
|
|
79
|
+
+ (CGRect)expandedHitRectFromCheckboxRect:(CGRect)rect {
|
|
80
|
+
if (CGRectIsNull(rect))
|
|
81
|
+
return rect;
|
|
82
|
+
|
|
83
|
+
return CGRectInset(rect, -kCheckboxHitSlopLeft, -kCheckboxHitSlopVertical);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// MARK: - Public API
|
|
87
|
+
|
|
88
|
+
+ (NSInteger)hitTestCheckboxAtPoint:(CGPoint)point
|
|
89
|
+
inInput:(EnrichedTextInputView *)input {
|
|
90
|
+
UITextView *textView = input->textView;
|
|
91
|
+
|
|
92
|
+
CGPoint containerPoint = [self containerPointFromViewPoint:point
|
|
93
|
+
textView:textView];
|
|
94
|
+
|
|
95
|
+
NSUInteger glyphIndex = [self glyphIndexAtContainerPoint:containerPoint
|
|
96
|
+
textView:textView];
|
|
97
|
+
|
|
98
|
+
if (glyphIndex == NSNotFound) {
|
|
99
|
+
return -1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (![self isCheckboxGlyph:glyphIndex inInput:input]) {
|
|
103
|
+
return -1;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
CGRect checkboxRect = [self checkboxRectForGlyphIndex:glyphIndex
|
|
107
|
+
inInput:input];
|
|
108
|
+
|
|
109
|
+
if (CGRectIsNull(checkboxRect)) {
|
|
110
|
+
return -1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
CGRect hitRect = [self expandedHitRectFromCheckboxRect:checkboxRect];
|
|
114
|
+
|
|
115
|
+
if (!CGRectContainsPoint(hitRect, containerPoint)) {
|
|
116
|
+
return -1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return [textView.layoutManager characterIndexForGlyphAtIndex:glyphIndex];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
@interface DotReplacementUtils : NSObject
|
|
5
|
+
+ (void)handleDotReplacement:(id)input
|
|
6
|
+
textStorage:(NSTextStorage *)textStorage
|
|
7
|
+
editedMask:(NSTextStorageEditActions)editedMask
|
|
8
|
+
editedRange:(NSRange)editedRange
|
|
9
|
+
delta:(NSInteger)delta;
|
|
10
|
+
@end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#import "DotReplacementUtils.h"
|
|
2
|
+
#import "EnrichedTextInputView.h"
|
|
3
|
+
|
|
4
|
+
@implementation DotReplacementUtils
|
|
5
|
+
|
|
6
|
+
// This is a fix for iOS replacing a space with a dot when two spaces are
|
|
7
|
+
// quickly inputted That operation doesn't properly extend our custom attributes
|
|
8
|
+
// and we do it here manually
|
|
9
|
+
+ (void)handleDotReplacement:(id)input
|
|
10
|
+
textStorage:(NSTextStorage *)textStorage
|
|
11
|
+
editedMask:(NSTextStorageEditActions)editedMask
|
|
12
|
+
editedRange:(NSRange)editedRange
|
|
13
|
+
delta:(NSInteger)delta {
|
|
14
|
+
EnrichedTextInputView *typedInput = (EnrichedTextInputView *)input;
|
|
15
|
+
if (typedInput == nullptr) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Conditions for the dot attributes fix:
|
|
20
|
+
// - character edition was done
|
|
21
|
+
// - it edited one character
|
|
22
|
+
// - new character is a dot
|
|
23
|
+
// - delta=0, meaning a replacement was done
|
|
24
|
+
// - there is something before the edited range to get attributes from
|
|
25
|
+
if ((editedMask & NSTextStorageEditedCharacters) != 0 &&
|
|
26
|
+
editedRange.length == 1 &&
|
|
27
|
+
[[textStorage.string substringWithRange:editedRange]
|
|
28
|
+
isEqualToString:@"."] &&
|
|
29
|
+
delta == 0 && editedRange.location > 0) {
|
|
30
|
+
// If all of the above are true, we are sure some dot replacement has been
|
|
31
|
+
// done So we manually need to apply the preceeding attribtues to the dot
|
|
32
|
+
NSDictionary *prevAttrs =
|
|
33
|
+
[textStorage attributesAtIndex:editedRange.location - 1
|
|
34
|
+
effectiveRange:nullptr];
|
|
35
|
+
[textStorage addAttributes:prevAttrs range:editedRange];
|
|
36
|
+
typedInput->dotReplacementRange = [NSValue valueWithRange:editedRange];
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Space after the dot added by iOS comes in a separate, second callback.
|
|
41
|
+
// Checking its conditions:
|
|
42
|
+
// - dotReplacementRange defined
|
|
43
|
+
// - dotReplacementRange was exactly before the new edited range
|
|
44
|
+
// - character edition was done
|
|
45
|
+
// - it edited one character
|
|
46
|
+
// - edited character is a space
|
|
47
|
+
// - delta=1, meaning addition was done
|
|
48
|
+
if (typedInput->dotReplacementRange != nullptr &&
|
|
49
|
+
[typedInput->dotReplacementRange rangeValue].location + 1 ==
|
|
50
|
+
editedRange.location &&
|
|
51
|
+
(editedMask & NSTextStorageEditedCharacters) != 0 &&
|
|
52
|
+
editedRange.length == 1 &&
|
|
53
|
+
[[textStorage.string substringWithRange:editedRange]
|
|
54
|
+
isEqualToString:@" "] &&
|
|
55
|
+
delta == 1) {
|
|
56
|
+
// If all of the above are true, we are now sure it was the iOS dot
|
|
57
|
+
// replacement Only then do we also fix attribtues of the space added
|
|
58
|
+
// afterwards
|
|
59
|
+
NSDictionary *prevAttrs =
|
|
60
|
+
[textStorage attributesAtIndex:editedRange.location - 1
|
|
61
|
+
effectiveRange:nullptr];
|
|
62
|
+
[textStorage addAttributes:prevAttrs range:editedRange];
|
|
63
|
+
}
|
|
64
|
+
// always reset the replacement range after any processing
|
|
65
|
+
typedInput->dotReplacementRange = nullptr;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@end
|