react-native-enriched-markdown-scaffold 0.6.0-scaffold.4
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 +53 -0
- package/ReactNativeEnrichedMarkdown.podspec +67 -0
- package/android/build.gradle +94 -0
- package/android/consumer-rules.pro +19 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +87 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +37 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerDelegate.java +159 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +59 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +87 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +37 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +318 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +259 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +375 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +5174 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/ShadowNodes.h +23 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/States.h +20 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/baseline-prof.txt +254 -0
- package/android/src/main/cpp/jni-adapter.cpp +264 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +554 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +122 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +255 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +363 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextLayoutManager.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +253 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextPackage.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +653 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/AccessibleMarkdownTextView.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/MarkdownAccessibilityHelper.kt +482 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/ContextMenuItemPressEvent.kt +28 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/LinkLongPressEvent.kt +23 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/LinkPressEvent.kt +23 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/TaskListItemPressEvent.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputManager.kt +465 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +1066 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/autolink/AutoDetectedLinkSpan.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/autolink/AutoLinkDetector.kt +188 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/autolink/LinkRegexConfig.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/detection/DetectorPipeline.kt +40 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/detection/TextDetector.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/detection/WordResult.kt +7 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/detection/WordsUtils.kt +65 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/InputConnectionWrapper.kt +69 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MarkdownEditableFactory.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MarkdownTextWatcher.kt +41 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnCaretRectChangeEvent.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnChangeMarkdownEvent.kt +22 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnChangeMentionEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnChangeSelectionEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnChangeStateEvent.kt +50 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnChangeTextEvent.kt +22 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnContextMenuItemPressEvent.kt +48 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnEndMentionEvent.kt +22 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnInputBlurEvent.kt +18 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnInputFocusEvent.kt +18 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnLinkDetectedEvent.kt +28 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnMathPressEvent.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnRequestCaretRectResultEvent.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnRequestMarkdownResultEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnStartMentionEvent.kt +22 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/FormattingStore.kt +192 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputFormatter.kt +117 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputParser.kt +117 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputRemend.kt +120 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/MarkdownSerializer.kt +176 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputEventEmitter.kt +216 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputLayoutManager.kt +28 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputMeasurementStore.kt +137 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/math/MathChipController.kt +113 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/CaretRect.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/FormattingRange.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/InputFormatterStyle.kt +28 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathAtom.kt +7 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathChipStyle.kt +47 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/StyleType.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/BoldStyleHandler.kt +35 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/ItalicStyleHandler.kt +35 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/LinkStyleHandler.kt +75 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/SpoilerStyleHandler.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/StrikethroughStyleHandler.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/StyleHandler.kt +18 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/StyleMergingConfig.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/UnderlineStyleHandler.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/toolbar/InputContextMenu.kt +181 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/MarkdownASTNode.kt +43 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +68 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BaselineShiftRenderer.kt +44 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockStyleContext.kt +152 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteRenderer.kt +87 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeBlockRenderer.kt +104 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeRenderer.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/DocumentRenderer.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/EmphasisRenderer.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HeadingRenderer.kt +71 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HighlightRenderer.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ImageRenderer.kt +61 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/LineBreakRenderer.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/LinkRenderer.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListContextManager.kt +89 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListItemRenderer.kt +127 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListRenderer.kt +74 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +161 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ParagraphRenderer.kt +75 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/Renderer.kt +113 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SpanStyleCache.kt +134 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SpoilerRenderer.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/StrikethroughRenderer.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/StrongRenderer.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SubscriptRenderer.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SuperscriptRenderer.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/TextRenderer.kt +30 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ThematicBreakRenderer.kt +45 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/UnderlineRenderer.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/BaseListSpan.kt +127 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/BaselineShiftSpan.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/BlockquoteSpan.kt +152 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBackgroundSpan.kt +180 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBlockSpan.kt +196 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeSpan.kt +32 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/EmphasisSpan.kt +42 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/FadeInSpan.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/HeadingSpan.kt +38 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/HighlightSpan.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ImageSpan.kt +335 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LineHeightSpan.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt +66 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/MarginBottomSpan.kt +76 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/MathModels.kt +18 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/OrderedListSpan.kt +85 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/SpoilerSpan.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/StrikethroughSpan.kt +12 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/StrongSpan.kt +39 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/TaskListSpan.kt +134 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/TextSpan.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ThematicBreakSpan.kt +69 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/UnorderedListSpan.kt +92 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/ParticleStrategy.kt +68 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SegmentKey.kt +13 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SolidStrategy.kt +95 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerAnimator.kt +89 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerCapable.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerConstants.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerDrawContext.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerDrawUtils.kt +40 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerOverlay.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerOverlayDrawer.kt +152 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerParticleDrawable.kt +237 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerStrategy.kt +53 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/BaseBlockStyle.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/BlockquoteStyle.kt +51 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/CodeBlockStyle.kt +54 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/CodeStyle.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/EmphasisStyle.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/HeadingStyle.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/HighlightStyle.kt +19 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ImageStyle.kt +23 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/InlineImageStyle.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/InlineMathStyle.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkStyle.kt +23 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkVariantEntry.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ListStyle.kt +62 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathStyle.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ParagraphStyle.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/SpoilerStyle.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StrikethroughStyle.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StrongStyle.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleConfig.kt +364 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleParser.kt +92 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/SubscriptStyle.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/SuperscriptStyle.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/TableStyle.kt +69 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/TaskListStyle.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/TextAlignment.kt +32 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ThematicBreakStyle.kt +23 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/UnderlineStyle.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/BreakStrategyUtils.kt +32 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/FeatureFlags.kt +7 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownSegment.kt +56 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +100 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MotionPreferences.kt +18 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/ReadableMapExtensions.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/RenderedSegment.kt +78 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/SegmentReconciler.kt +118 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/SegmentSignature.kt +78 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/StreamingMarkdownFilter.kt +142 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/layout/RTLUtils.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt +115 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/AutoCapitalizeUtils.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/BorderPropsApplicator.kt +77 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/MarkdownStyleParser.kt +184 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/ImageCache.kt +53 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/ImageDownloader.kt +156 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/TailFadeInAnimator.kt +84 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/HTMLGenerator.kt +1067 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/MarkdownExtractor.kt +419 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/ParagraphUtils.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/SpannableExtensions.kt +65 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/TextPaintExtensions.kt +53 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/interaction/CheckboxTouchHelper.kt +54 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/interaction/TaskListTapUtils.kt +249 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/BlockSpacing.kt +89 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/SpanFlags.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkEvents.kt +43 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLongPressMovementMethod.kt +187 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionActionMode.kt +205 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/TextSelectionColors.kt +48 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/TextViewSetup.kt +40 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/BlockSegmentView.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/ContextMenuPopup.kt +214 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/TableContainerView.kt +501 -0
- package/android/src/main/jni/CMakeLists.txt +70 -0
- package/android/src/main/jni/EnrichedMarkdownTextSpec.cpp +21 -0
- package/android/src/main/jni/EnrichedMarkdownTextSpec.h +15 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/ComponentDescriptors.h +67 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownContainerComponentDescriptor.h +26 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownContainerMeasurementManager.cpp +45 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownContainerMeasurementManager.h +21 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownContainerShadowNode.cpp +20 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownContainerShadowNode.h +34 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextComponentDescriptor.h +29 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputMeasurementManager.cpp +44 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputMeasurementManager.h +21 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputShadowNode.cpp +30 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputShadowNode.h +43 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputState.cpp +9 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextInputState.h +24 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextMeasurementManager.cpp +45 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextMeasurementManager.h +21 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextShadowNode.cpp +20 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextShadowNode.h +37 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/conversions.h +45 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/input/math/MathChipControllerImpl.kt +217 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +47 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathChipSpan.kt +208 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlinePlaceholderSpan.kt +41 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +92 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathMeasureHelper.kt +57 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +148 -0
- package/app.plugin.js +1 -0
- package/cpp/md4c/md4c.c +7235 -0
- package/cpp/md4c/md4c.h +475 -0
- package/cpp/parser/MD4CParser.cpp +539 -0
- package/cpp/parser/MD4CParser.hpp +32 -0
- package/cpp/parser/MarkdownASTNode.hpp +63 -0
- package/cpp/wasm/ASTSerializer.cpp +158 -0
- package/cpp/wasm/ASTSerializer.hpp +17 -0
- package/cpp/wasm/build.sh +58 -0
- package/cpp/wasm/md4c_wasm.cpp +43 -0
- package/ios/EnrichedMarkdown.h +20 -0
- package/ios/EnrichedMarkdown.mm +1121 -0
- package/ios/EnrichedMarkdownText.h +20 -0
- package/ios/EnrichedMarkdownText.mm +802 -0
- package/ios/attachments/ENRMImageAttachment.h +27 -0
- package/ios/attachments/ENRMImageAttachment.m +305 -0
- package/ios/attachments/ENRMMathInlineAttachment+macOS.m +60 -0
- package/ios/attachments/ENRMMathInlineAttachment.h +47 -0
- package/ios/attachments/ENRMMathInlineAttachment.m +142 -0
- package/ios/attachments/ENRMMathInlineAttachmentShared.h +17 -0
- package/ios/attachments/ThematicBreakAttachment.h +15 -0
- package/ios/attachments/ThematicBreakAttachment.m +33 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +318 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +259 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +375 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +5174 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/RCTComponentViewHelpers.h +436 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/ShadowNodes.h +23 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/States.cpp +16 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/States.h +20 -0
- package/ios/input/ENRMAutoLinkDetector.h +32 -0
- package/ios/input/ENRMAutoLinkDetector.mm +211 -0
- package/ios/input/ENRMDetectorPipeline.h +28 -0
- package/ios/input/ENRMDetectorPipeline.mm +53 -0
- package/ios/input/ENRMFormattingRange.h +19 -0
- package/ios/input/ENRMFormattingRange.mm +28 -0
- package/ios/input/ENRMFormattingStore.h +29 -0
- package/ios/input/ENRMFormattingStore.mm +278 -0
- package/ios/input/ENRMInputFormatter.h +84 -0
- package/ios/input/ENRMInputFormatter.mm +222 -0
- package/ios/input/ENRMInputLayoutManager.h +11 -0
- package/ios/input/ENRMInputLayoutManager.mm +5 -0
- package/ios/input/ENRMInputLinkPrompt.h +9 -0
- package/ios/input/ENRMInputLinkPrompt.mm +71 -0
- package/ios/input/ENRMInputMentionCandidate.h +21 -0
- package/ios/input/ENRMInputMentionCandidate.mm +18 -0
- package/ios/input/ENRMInputParser.h +27 -0
- package/ios/input/ENRMInputParser.mm +556 -0
- package/ios/input/ENRMInputRemend.h +9 -0
- package/ios/input/ENRMInputRemend.mm +136 -0
- package/ios/input/ENRMInputStyledRange.h +29 -0
- package/ios/input/ENRMInputStyledRange.mm +4 -0
- package/ios/input/ENRMInputTextView.h +13 -0
- package/ios/input/ENRMInputTextView.mm +175 -0
- package/ios/input/ENRMLinkRegexConfig.h +26 -0
- package/ios/input/ENRMLinkRegexConfig.mm +60 -0
- package/ios/input/ENRMMarkdownSerializer.h +19 -0
- package/ios/input/ENRMMarkdownSerializer.mm +283 -0
- package/ios/input/ENRMTextDetector.h +30 -0
- package/ios/input/ENRMWordsUtils.h +28 -0
- package/ios/input/ENRMWordsUtils.mm +88 -0
- package/ios/input/EnrichedMarkdownTextInput+ContextMenu.mm +157 -0
- package/ios/input/EnrichedMarkdownTextInput+Internal.h +30 -0
- package/ios/input/EnrichedMarkdownTextInput.h +20 -0
- package/ios/input/EnrichedMarkdownTextInput.mm +2008 -0
- package/ios/input/InputStylePropsUtils.h +261 -0
- package/ios/input/internals/EnrichedMarkdownTextInputComponentDescriptor.h +19 -0
- package/ios/input/internals/EnrichedMarkdownTextInputShadowNode.h +40 -0
- package/ios/input/internals/EnrichedMarkdownTextInputShadowNode.mm +83 -0
- package/ios/input/internals/EnrichedMarkdownTextInputState.h +23 -0
- package/ios/input/styles/ENRMBoldStyleHandler.h +10 -0
- package/ios/input/styles/ENRMBoldStyleHandler.mm +29 -0
- package/ios/input/styles/ENRMItalicStyleHandler.h +10 -0
- package/ios/input/styles/ENRMItalicStyleHandler.mm +29 -0
- package/ios/input/styles/ENRMLinkStyleHandler.h +10 -0
- package/ios/input/styles/ENRMLinkStyleHandler.mm +52 -0
- package/ios/input/styles/ENRMSpoilerStyleHandler.h +10 -0
- package/ios/input/styles/ENRMSpoilerStyleHandler.mm +33 -0
- package/ios/input/styles/ENRMStrikethroughStyleHandler.h +10 -0
- package/ios/input/styles/ENRMStrikethroughStyleHandler.mm +28 -0
- package/ios/input/styles/ENRMStyleHandler.h +26 -0
- package/ios/input/styles/ENRMStyleMergingConfig.h +26 -0
- package/ios/input/styles/ENRMStyleMergingConfig.mm +21 -0
- package/ios/input/styles/ENRMUnderlineStyleHandler.h +10 -0
- package/ios/input/styles/ENRMUnderlineStyleHandler.mm +28 -0
- package/ios/internals/EnrichedMarkdownComponentDescriptor.h +18 -0
- package/ios/internals/EnrichedMarkdownShadowNode.h +43 -0
- package/ios/internals/EnrichedMarkdownShadowNode.mm +73 -0
- package/ios/internals/EnrichedMarkdownState.h +23 -0
- package/ios/internals/EnrichedMarkdownTextComponentDescriptor.h +19 -0
- package/ios/internals/EnrichedMarkdownTextShadowNode.h +45 -0
- package/ios/internals/EnrichedMarkdownTextShadowNode.mm +74 -0
- package/ios/internals/EnrichedMarkdownTextState.h +24 -0
- package/ios/internals/MeasurementCache.h +223 -0
- package/ios/internals/ShadowMeasurementUtils.h +135 -0
- package/ios/math/ENRMRaTeXBridge.swift +58 -0
- package/ios/parser/ENRMMarkdownParser.h +21 -0
- package/ios/parser/ENRMMarkdownParser.mm +50 -0
- package/ios/parser/MarkdownASTNode.h +47 -0
- package/ios/parser/MarkdownASTNode.m +32 -0
- package/ios/parser/MarkdownParserBridge.mm +161 -0
- package/ios/renderer/AttributedRenderer.h +11 -0
- package/ios/renderer/AttributedRenderer.m +153 -0
- package/ios/renderer/BaseRenderer.h +18 -0
- package/ios/renderer/BaseRenderer.m +16 -0
- package/ios/renderer/BaselineShiftTextAttributes.h +6 -0
- package/ios/renderer/BaselineShiftTextAttributes.m +22 -0
- package/ios/renderer/BlockquoteRenderer.h +6 -0
- package/ios/renderer/BlockquoteRenderer.m +148 -0
- package/ios/renderer/CodeBlockRenderer.h +9 -0
- package/ios/renderer/CodeBlockRenderer.m +90 -0
- package/ios/renderer/CodeRenderer.h +9 -0
- package/ios/renderer/CodeRenderer.m +64 -0
- package/ios/renderer/ENRMImageRenderer.h +9 -0
- package/ios/renderer/ENRMImageRenderer.m +65 -0
- package/ios/renderer/ENRMMathInlineRenderer.h +9 -0
- package/ios/renderer/ENRMMathInlineRenderer.m +56 -0
- package/ios/renderer/ENRMSpoilerRenderer.h +5 -0
- package/ios/renderer/ENRMSpoilerRenderer.m +32 -0
- package/ios/renderer/EmphasisRenderer.h +5 -0
- package/ios/renderer/EmphasisRenderer.m +98 -0
- package/ios/renderer/HeadingRenderer.h +6 -0
- package/ios/renderer/HeadingRenderer.m +94 -0
- package/ios/renderer/HighlightRenderer.h +7 -0
- package/ios/renderer/HighlightRenderer.m +31 -0
- package/ios/renderer/LinkRenderer.h +6 -0
- package/ios/renderer/LinkRenderer.m +82 -0
- package/ios/renderer/ListItemRenderer.h +12 -0
- package/ios/renderer/ListItemRenderer.m +175 -0
- package/ios/renderer/ListRenderer.h +13 -0
- package/ios/renderer/ListRenderer.m +70 -0
- package/ios/renderer/NodeRenderer.h +8 -0
- package/ios/renderer/ParagraphRenderer.h +6 -0
- package/ios/renderer/ParagraphRenderer.m +70 -0
- package/ios/renderer/RenderContext.h +118 -0
- package/ios/renderer/RenderContext.m +337 -0
- package/ios/renderer/RendererFactory.h +12 -0
- package/ios/renderer/RendererFactory.m +147 -0
- package/ios/renderer/StrikethroughRenderer.h +5 -0
- package/ios/renderer/StrikethroughRenderer.m +28 -0
- package/ios/renderer/StrongRenderer.h +5 -0
- package/ios/renderer/StrongRenderer.m +86 -0
- package/ios/renderer/SubscriptRenderer.h +5 -0
- package/ios/renderer/SubscriptRenderer.m +22 -0
- package/ios/renderer/SuperscriptRenderer.h +5 -0
- package/ios/renderer/SuperscriptRenderer.m +22 -0
- package/ios/renderer/TextRenderer.h +6 -0
- package/ios/renderer/TextRenderer.m +16 -0
- package/ios/renderer/ThematicBreakRenderer.h +4 -0
- package/ios/renderer/ThematicBreakRenderer.m +40 -0
- package/ios/renderer/UnderlineRenderer.h +4 -0
- package/ios/renderer/UnderlineRenderer.m +27 -0
- package/ios/styles/ENRMFontSlot.h +12 -0
- package/ios/styles/ENRMFontSlot.m +24 -0
- package/ios/styles/StyleConfig.h +407 -0
- package/ios/styles/StyleConfig.mm +2515 -0
- package/ios/utils/AccessibilityInfo.h +35 -0
- package/ios/utils/AccessibilityInfo.m +24 -0
- package/ios/utils/BlockquoteBorder.h +20 -0
- package/ios/utils/BlockquoteBorder.m +97 -0
- package/ios/utils/CodeBackground.h +19 -0
- package/ios/utils/CodeBackground.m +197 -0
- package/ios/utils/CodeBlockBackground.h +17 -0
- package/ios/utils/CodeBlockBackground.m +89 -0
- package/ios/utils/ContextMenuUtils.h +76 -0
- package/ios/utils/ContextMenuUtils.mm +73 -0
- package/ios/utils/ENRMAsyncRenderCoordinator.h +24 -0
- package/ios/utils/ENRMAsyncRenderCoordinator.m +37 -0
- package/ios/utils/ENRMFeatureFlags.h +12 -0
- package/ios/utils/ENRMImageDownloader.h +16 -0
- package/ios/utils/ENRMImageDownloader.m +108 -0
- package/ios/utils/ENRMMenuAction.h +27 -0
- package/ios/utils/ENRMMenuAction.m +33 -0
- package/ios/utils/ENRMParticleOverlayView.h +12 -0
- package/ios/utils/ENRMParticleOverlayView.m +159 -0
- package/ios/utils/ENRMSolidOverlayView.h +12 -0
- package/ios/utils/ENRMSolidOverlayView.m +25 -0
- package/ios/utils/ENRMSpoilerCapable.h +15 -0
- package/ios/utils/ENRMSpoilerOverlayManager.h +21 -0
- package/ios/utils/ENRMSpoilerOverlayManager.m +181 -0
- package/ios/utils/ENRMSpoilerOverlayView.h +49 -0
- package/ios/utils/ENRMSpoilerOverlayView.m +144 -0
- package/ios/utils/ENRMSpoilerTapUtils.h +25 -0
- package/ios/utils/ENRMSpoilerTapUtils.m +68 -0
- package/ios/utils/ENRMTailFadeInAnimator.h +16 -0
- package/ios/utils/ENRMTailFadeInAnimator.m +161 -0
- package/ios/utils/ENRMTextHitTest.h +23 -0
- package/ios/utils/ENRMTextHitTest.m +20 -0
- package/ios/utils/ENRMTextInteractionUtils.h +20 -0
- package/ios/utils/ENRMTextInteractionUtils.m +15 -0
- package/ios/utils/ENRMTextRenderer.h +30 -0
- package/ios/utils/ENRMTextRenderer.m +38 -0
- package/ios/utils/ENRMTextViewSetup.h +78 -0
- package/ios/utils/ENRMUIKit.h +418 -0
- package/ios/utils/EditMenuUtils+macOS.m +60 -0
- package/ios/utils/EditMenuUtils.h +35 -0
- package/ios/utils/EditMenuUtils.m +119 -0
- package/ios/utils/FontScaleObserver.h +10 -0
- package/ios/utils/FontScaleObserver.m +55 -0
- package/ios/utils/FontUtils.h +30 -0
- package/ios/utils/FontUtils.m +47 -0
- package/ios/utils/HTMLGenerator.h +25 -0
- package/ios/utils/HTMLGenerator.m +1019 -0
- package/ios/utils/HeightUpdateUtils.h +25 -0
- package/ios/utils/LastElementUtils.h +53 -0
- package/ios/utils/LinkTapUtils.h +24 -0
- package/ios/utils/LinkTapUtils.m +32 -0
- package/ios/utils/ListMarkerDrawer.h +15 -0
- package/ios/utils/ListMarkerDrawer.m +212 -0
- package/ios/utils/MarkdownASTSerializer.h +24 -0
- package/ios/utils/MarkdownASTSerializer.m +114 -0
- package/ios/utils/MarkdownAccessibilityElementBuilder.h +41 -0
- package/ios/utils/MarkdownAccessibilityElementBuilder.m +450 -0
- package/ios/utils/MarkdownExtractor.h +17 -0
- package/ios/utils/MarkdownExtractor.m +355 -0
- package/ios/utils/ParagraphStyleUtils.h +53 -0
- package/ios/utils/ParagraphStyleUtils.m +349 -0
- package/ios/utils/PasteboardUtils.h +48 -0
- package/ios/utils/PasteboardUtils.m +162 -0
- package/ios/utils/RTFExportUtils.h +24 -0
- package/ios/utils/RTFExportUtils.m +297 -0
- package/ios/utils/RenderedMarkdownSegment.h +49 -0
- package/ios/utils/RenderedMarkdownSegment.m +130 -0
- package/ios/utils/RuntimeKeys.h +38 -0
- package/ios/utils/RuntimeKeys.m +11 -0
- package/ios/utils/SegmentReconciler.h +32 -0
- package/ios/utils/SegmentReconciler.m +118 -0
- package/ios/utils/SegmentRenderer.h +24 -0
- package/ios/utils/SegmentRenderer.m +88 -0
- package/ios/utils/SegmentViewRegistry.h +36 -0
- package/ios/utils/SegmentViewRegistry.m +67 -0
- package/ios/utils/SelectionColorUtils.h +14 -0
- package/ios/utils/StreamingMarkdownFilter.h +22 -0
- package/ios/utils/StreamingMarkdownFilter.m +165 -0
- package/ios/utils/StylePropsUtils.h +1146 -0
- package/ios/utils/TaskListTapUtils.h +43 -0
- package/ios/utils/TaskListTapUtils.m +227 -0
- package/ios/utils/TextViewLayoutManager.h +14 -0
- package/ios/utils/TextViewLayoutManager.mm +113 -0
- package/ios/views/ENRMContextMenuTextView+macOS.h +17 -0
- package/ios/views/ENRMContextMenuTextView+macOS.m +97 -0
- package/ios/views/ENRMMathContainerView.h +20 -0
- package/ios/views/ENRMMathContainerView.m +227 -0
- package/ios/views/ENRMTableGridView.h +36 -0
- package/ios/views/ENRMTableGridView.m +98 -0
- package/ios/views/EnrichedMarkdownInternalText.h +42 -0
- package/ios/views/EnrichedMarkdownInternalText.m +161 -0
- package/ios/views/TableContainerView.h +39 -0
- package/ios/views/TableContainerView.m +686 -0
- package/lib/module/EnrichedMarkdownNativeComponent.ts +429 -0
- package/lib/module/EnrichedMarkdownTextInput.js +310 -0
- package/lib/module/EnrichedMarkdownTextInput.js.map +1 -0
- package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +364 -0
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +428 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/index.web.js +4 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/module/linkVariantUtils.js +28 -0
- package/lib/module/linkVariantUtils.js.map +1 -0
- package/lib/module/native/EnrichedMarkdownText.js +158 -0
- package/lib/module/native/EnrichedMarkdownText.js.map +1 -0
- package/lib/module/normalizeMarkdownStyle.js +337 -0
- package/lib/module/normalizeMarkdownStyle.js.map +1 -0
- package/lib/module/normalizeMarkdownStyle.web.js +264 -0
- package/lib/module/normalizeMarkdownStyle.web.js.map +1 -0
- package/lib/module/normalizeMarkdownTextInputStyle.js +146 -0
- package/lib/module/normalizeMarkdownTextInputStyle.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/plugin/withAndroidMath.js +20 -0
- package/lib/module/plugin/withAndroidMath.js.map +1 -0
- package/lib/module/plugin/withIosMath.js +23 -0
- package/lib/module/plugin/withIosMath.js.map +1 -0
- package/lib/module/plugin/withReactNativeEnrichedMarkdown.js +16 -0
- package/lib/module/plugin/withReactNativeEnrichedMarkdown.js.map +1 -0
- package/lib/module/styleUtils.js +64 -0
- package/lib/module/styleUtils.js.map +1 -0
- package/lib/module/types/MarkdownStyle.js +2 -0
- package/lib/module/types/MarkdownStyle.js.map +1 -0
- package/lib/module/types/MarkdownStyleInternal.js +2 -0
- package/lib/module/types/MarkdownStyleInternal.js.map +1 -0
- package/lib/module/types/MarkdownTextProps.js +4 -0
- package/lib/module/types/MarkdownTextProps.js.map +1 -0
- package/lib/module/types/MarkdownTextProps.web.js +4 -0
- package/lib/module/types/MarkdownTextProps.web.js.map +1 -0
- package/lib/module/types/events.js +2 -0
- package/lib/module/types/events.js.map +1 -0
- package/lib/module/utils/regexParser.js +43 -0
- package/lib/module/utils/regexParser.js.map +1 -0
- package/lib/module/web/EnrichedMarkdownText.js +120 -0
- package/lib/module/web/EnrichedMarkdownText.js.map +1 -0
- package/lib/module/web/globalStyles.js +10 -0
- package/lib/module/web/globalStyles.js.map +1 -0
- package/lib/module/web/injectStyle.js +20 -0
- package/lib/module/web/injectStyle.js.map +1 -0
- package/lib/module/web/katex.js +22 -0
- package/lib/module/web/katex.js.map +1 -0
- package/lib/module/web/parseMarkdown.js +35 -0
- package/lib/module/web/parseMarkdown.js.map +1 -0
- package/lib/module/web/renderers/BlockRenderers.js +115 -0
- package/lib/module/web/renderers/BlockRenderers.js.map +1 -0
- package/lib/module/web/renderers/InlineRenderers.js +160 -0
- package/lib/module/web/renderers/InlineRenderers.js.map +1 -0
- package/lib/module/web/renderers/KaTeXRenderer.js +43 -0
- package/lib/module/web/renderers/KaTeXRenderer.js.map +1 -0
- package/lib/module/web/renderers/ListRenderers.js +92 -0
- package/lib/module/web/renderers/ListRenderers.js.map +1 -0
- package/lib/module/web/renderers/TableRenderers.js +77 -0
- package/lib/module/web/renderers/TableRenderers.js.map +1 -0
- package/lib/module/web/renderers/index.js +49 -0
- package/lib/module/web/renderers/index.js.map +1 -0
- package/lib/module/web/styles.js +454 -0
- package/lib/module/web/styles.js.map +1 -0
- package/lib/module/web/types.js +4 -0
- package/lib/module/web/types.js.map +1 -0
- package/lib/module/web/utils.js +56 -0
- package/lib/module/web/utils.js.map +1 -0
- package/lib/module/web/wasm/md4c.d.js +4 -0
- package/lib/module/web/wasm/md4c.d.js.map +1 -0
- package/lib/module/web/wasm/md4c.js +0 -0
- package/lib/module/web/wasm/md4c.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +384 -0
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +173 -0
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -0
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +285 -0
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +384 -0
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/index.web.d.ts +5 -0
- package/lib/typescript/src/index.web.d.ts.map +1 -0
- package/lib/typescript/src/linkVariantUtils.d.ts +5 -0
- package/lib/typescript/src/linkVariantUtils.d.ts.map +1 -0
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +9 -0
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts.map +1 -0
- package/lib/typescript/src/normalizeMarkdownStyle.d.ts +4 -0
- package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -0
- package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts +4 -0
- package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -0
- package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts +48 -0
- package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts.map +1 -0
- package/lib/typescript/src/plugin/withAndroidMath.d.ts +5 -0
- package/lib/typescript/src/plugin/withAndroidMath.d.ts.map +1 -0
- package/lib/typescript/src/plugin/withIosMath.d.ts +5 -0
- package/lib/typescript/src/plugin/withIosMath.d.ts.map +1 -0
- package/lib/typescript/src/plugin/withReactNativeEnrichedMarkdown.d.ts +6 -0
- package/lib/typescript/src/plugin/withReactNativeEnrichedMarkdown.d.ts.map +1 -0
- package/lib/typescript/src/styleUtils.d.ts +6 -0
- package/lib/typescript/src/styleUtils.d.ts.map +1 -0
- package/lib/typescript/src/types/MarkdownStyle.d.ts +300 -0
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +178 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -0
- package/lib/typescript/src/types/MarkdownTextProps.d.ts +249 -0
- package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -0
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +83 -0
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -0
- package/lib/typescript/src/types/events.d.ts +29 -0
- package/lib/typescript/src/types/events.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/EnrichedMarkdownText.d.ts +4 -0
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts.map +1 -0
- package/lib/typescript/src/web/globalStyles.d.ts +3 -0
- package/lib/typescript/src/web/globalStyles.d.ts.map +1 -0
- package/lib/typescript/src/web/injectStyle.d.ts +9 -0
- package/lib/typescript/src/web/injectStyle.d.ts.map +1 -0
- package/lib/typescript/src/web/katex.d.ts +11 -0
- package/lib/typescript/src/web/katex.d.ts.map +1 -0
- package/lib/typescript/src/web/parseMarkdown.d.ts +4 -0
- package/lib/typescript/src/web/parseMarkdown.d.ts.map +1 -0
- package/lib/typescript/src/web/renderers/BlockRenderers.d.ts +3 -0
- package/lib/typescript/src/web/renderers/BlockRenderers.d.ts.map +1 -0
- package/lib/typescript/src/web/renderers/InlineRenderers.d.ts +3 -0
- package/lib/typescript/src/web/renderers/InlineRenderers.d.ts.map +1 -0
- package/lib/typescript/src/web/renderers/KaTeXRenderer.d.ts +11 -0
- package/lib/typescript/src/web/renderers/KaTeXRenderer.d.ts.map +1 -0
- package/lib/typescript/src/web/renderers/ListRenderers.d.ts +3 -0
- package/lib/typescript/src/web/renderers/ListRenderers.d.ts.map +1 -0
- package/lib/typescript/src/web/renderers/TableRenderers.d.ts +3 -0
- package/lib/typescript/src/web/renderers/TableRenderers.d.ts.map +1 -0
- package/lib/typescript/src/web/renderers/index.d.ts +14 -0
- package/lib/typescript/src/web/renderers/index.d.ts.map +1 -0
- package/lib/typescript/src/web/styles.d.ts +49 -0
- package/lib/typescript/src/web/styles.d.ts.map +1 -0
- package/lib/typescript/src/web/types.d.ts +51 -0
- package/lib/typescript/src/web/types.d.ts.map +1 -0
- package/lib/typescript/src/web/utils.d.ts +21 -0
- package/lib/typescript/src/web/utils.d.ts.map +1 -0
- package/package.json +125 -0
- package/react-native.config.js +17 -0
- package/src/EnrichedMarkdownNativeComponent.ts +429 -0
- package/src/EnrichedMarkdownTextInput.tsx +547 -0
- package/src/EnrichedMarkdownTextInputNativeComponent.ts +364 -0
- package/src/EnrichedMarkdownTextNativeComponent.ts +428 -0
- package/src/index.tsx +28 -0
- package/src/index.web.tsx +8 -0
- package/src/linkVariantUtils.ts +42 -0
- package/src/native/EnrichedMarkdownText.tsx +187 -0
- package/src/normalizeMarkdownStyle.ts +310 -0
- package/src/normalizeMarkdownStyle.web.ts +281 -0
- package/src/normalizeMarkdownTextInputStyle.ts +242 -0
- package/src/plugin/withAndroidMath.ts +24 -0
- package/src/plugin/withIosMath.ts +35 -0
- package/src/plugin/withReactNativeEnrichedMarkdown.ts +17 -0
- package/src/styleUtils.ts +98 -0
- package/src/types/MarkdownStyle.ts +326 -0
- package/src/types/MarkdownStyleInternal.ts +208 -0
- package/src/types/MarkdownTextProps.ts +253 -0
- package/src/types/MarkdownTextProps.web.ts +90 -0
- package/src/types/events.ts +32 -0
- package/src/utils/regexParser.ts +54 -0
- package/src/web/EnrichedMarkdownText.tsx +154 -0
- package/src/web/globalStyles.ts +15 -0
- package/src/web/injectStyle.ts +17 -0
- package/src/web/katex.ts +31 -0
- package/src/web/parseMarkdown.ts +78 -0
- package/src/web/renderers/BlockRenderers.tsx +90 -0
- package/src/web/renderers/InlineRenderers.tsx +121 -0
- package/src/web/renderers/KaTeXRenderer.tsx +49 -0
- package/src/web/renderers/ListRenderers.tsx +110 -0
- package/src/web/renderers/TableRenderers.tsx +61 -0
- package/src/web/renderers/index.tsx +75 -0
- package/src/web/styles.ts +549 -0
- package/src/web/types.ts +92 -0
- package/src/web/utils.ts +52 -0
- package/src/web/wasm/md4c.d.ts +21 -0
- package/src/web/wasm/md4c.js +0 -0
|
@@ -0,0 +1,1121 @@
|
|
|
1
|
+
#import "EnrichedMarkdown.h"
|
|
2
|
+
#import "ContextMenuUtils.h"
|
|
3
|
+
#import "ENRMAsyncRenderCoordinator.h"
|
|
4
|
+
#import "ENRMImageAttachment.h"
|
|
5
|
+
#import "ENRMMarkdownParser.h"
|
|
6
|
+
#import "ENRMTailFadeInAnimator.h"
|
|
7
|
+
#import "ENRMTextInteractionUtils.h"
|
|
8
|
+
#import "ENRMTextRenderer.h"
|
|
9
|
+
#import "ENRMTextViewSetup.h"
|
|
10
|
+
#import "ENRMUIKit.h"
|
|
11
|
+
#import "EditMenuUtils.h"
|
|
12
|
+
|
|
13
|
+
#import "ENRMFeatureFlags.h"
|
|
14
|
+
|
|
15
|
+
#if ENRICHED_MARKDOWN_MATH
|
|
16
|
+
#import "ENRMMathContainerView.h"
|
|
17
|
+
#endif
|
|
18
|
+
#import "ENRMSpoilerCapable.h"
|
|
19
|
+
#import "ENRMSpoilerOverlayView.h"
|
|
20
|
+
#import "ENRMSpoilerTapUtils.h"
|
|
21
|
+
#import "EnrichedMarkdownInternalText.h"
|
|
22
|
+
#import "FontScaleObserver.h"
|
|
23
|
+
#import "FontUtils.h"
|
|
24
|
+
#import "HeightUpdateUtils.h"
|
|
25
|
+
#import "LastElementUtils.h"
|
|
26
|
+
#import "LinkTapUtils.h"
|
|
27
|
+
#import "MarkdownASTNode.h"
|
|
28
|
+
#import "MarkdownAccessibilityElementBuilder.h"
|
|
29
|
+
#import "MarkdownExtractor.h"
|
|
30
|
+
#import "MeasurementCache.h"
|
|
31
|
+
#import "ParagraphStyleUtils.h"
|
|
32
|
+
#import "RenderedMarkdownSegment.h"
|
|
33
|
+
#import "RuntimeKeys.h"
|
|
34
|
+
#import "SegmentReconciler.h"
|
|
35
|
+
#import "SegmentRenderer.h"
|
|
36
|
+
#import "SegmentViewRegistry.h"
|
|
37
|
+
#import "SelectionColorUtils.h"
|
|
38
|
+
#import "StreamingMarkdownFilter.h"
|
|
39
|
+
#import "StyleConfig.h"
|
|
40
|
+
#import "StylePropsUtils.h"
|
|
41
|
+
#import "TableContainerView.h"
|
|
42
|
+
#import "TaskListTapUtils.h"
|
|
43
|
+
#import "TextViewLayoutManager.h"
|
|
44
|
+
#import <React/RCTUtils.h>
|
|
45
|
+
#import <objc/runtime.h>
|
|
46
|
+
|
|
47
|
+
#import <ReactNativeEnrichedMarkdown/EnrichedMarkdownComponentDescriptor.h>
|
|
48
|
+
#import <ReactNativeEnrichedMarkdown/EventEmitters.h>
|
|
49
|
+
#import <ReactNativeEnrichedMarkdown/Props.h>
|
|
50
|
+
#import <ReactNativeEnrichedMarkdown/RCTComponentViewHelpers.h>
|
|
51
|
+
|
|
52
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
53
|
+
#import <React/RCTConversions.h>
|
|
54
|
+
#import <React/RCTFont.h>
|
|
55
|
+
#import <React/RCTI18nUtil.h>
|
|
56
|
+
|
|
57
|
+
using namespace facebook::react;
|
|
58
|
+
|
|
59
|
+
typedef NS_OPTIONS(NSUInteger, ENRMDirtyFlags) {
|
|
60
|
+
ENRMDirtyNone = 0,
|
|
61
|
+
ENRMDirtyRecreateSegments = 1 << 0,
|
|
62
|
+
ENRMDirtyForceHeight = 1 << 1,
|
|
63
|
+
ENRMDirtyRender = 1 << 2,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
static char kENRMSegmentFadeAnimatorKey;
|
|
67
|
+
|
|
68
|
+
@interface EnrichedMarkdown () <RCTEnrichedMarkdownViewProtocol, UITextViewDelegate>
|
|
69
|
+
- (void)emitLinkPress:(NSString *)url;
|
|
70
|
+
- (void)emitLinkLongPress:(NSString *)url;
|
|
71
|
+
- (void)emitTaskListItemPress:(NSInteger)index checked:(BOOL)checked text:(NSString *)text;
|
|
72
|
+
- (void)emitContextMenuItemPress:(NSString *)itemText
|
|
73
|
+
selectedText:(NSString *)selectedText
|
|
74
|
+
selectionStart:(NSUInteger)selectionStart
|
|
75
|
+
selectionEnd:(NSUInteger)selectionEnd;
|
|
76
|
+
@end
|
|
77
|
+
|
|
78
|
+
@implementation EnrichedMarkdown {
|
|
79
|
+
ENRMMarkdownParser *_parser;
|
|
80
|
+
StyleConfig *_config;
|
|
81
|
+
ENRMMd4cFlags *_md4cFlags;
|
|
82
|
+
NSString *_cachedMarkdown;
|
|
83
|
+
NSString *_renderedMarkdown;
|
|
84
|
+
NSMutableArray<RCTUIView *> *_segmentViews;
|
|
85
|
+
NSMutableArray<NSNumber *> *_segmentSignatures;
|
|
86
|
+
ENRMSegmentViewRegistry *_segmentViewRegistry;
|
|
87
|
+
ENRMDirtyFlags _dirtyFlags;
|
|
88
|
+
|
|
89
|
+
ENRMAsyncRenderCoordinator *_renderCoordinator;
|
|
90
|
+
|
|
91
|
+
EnrichedMarkdownShadowNode::ConcreteState::Shared _state;
|
|
92
|
+
int _heightUpdateCounter;
|
|
93
|
+
|
|
94
|
+
FontScaleObserver *_fontScaleObserver;
|
|
95
|
+
CGFloat _maxFontSizeMultiplier;
|
|
96
|
+
|
|
97
|
+
BOOL _allowTrailingMargin;
|
|
98
|
+
BOOL _selectable;
|
|
99
|
+
BOOL _enableLinkPreview;
|
|
100
|
+
BOOL _streamingAnimation;
|
|
101
|
+
ENRMTableStreamingMode _tableStreamingMode;
|
|
102
|
+
|
|
103
|
+
size_t _renderedStyleFingerprint;
|
|
104
|
+
size_t _pendingStyleFingerprint;
|
|
105
|
+
|
|
106
|
+
NSArray<NSString *> *_contextMenuItemTexts;
|
|
107
|
+
NSArray<NSString *> *_contextMenuItemIcons;
|
|
108
|
+
ENRMSelectionMenuConfig _selectionMenuConfig;
|
|
109
|
+
|
|
110
|
+
ENRMSpoilerOverlay _spoilerOverlay;
|
|
111
|
+
|
|
112
|
+
NSLineBreakStrategy _lineBreakStrategy;
|
|
113
|
+
|
|
114
|
+
ENRMWritingDirectionMode _writingDirectionMode;
|
|
115
|
+
NSWritingDirection _resolvedLayoutDirection;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
119
|
+
{
|
|
120
|
+
return concreteComponentDescriptorProvider<EnrichedMarkdownComponentDescriptor>();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
124
|
+
{
|
|
125
|
+
if (self = [super initWithFrame:frame]) {
|
|
126
|
+
static const auto defaultProps = std::make_shared<const EnrichedMarkdownProps>();
|
|
127
|
+
_props = defaultProps;
|
|
128
|
+
|
|
129
|
+
self.backgroundColor = [RCTUIColor clearColor];
|
|
130
|
+
_parser = [[ENRMMarkdownParser alloc] init];
|
|
131
|
+
_md4cFlags = [ENRMMd4cFlags defaultFlags];
|
|
132
|
+
_segmentViews = [NSMutableArray array];
|
|
133
|
+
_segmentSignatures = [NSMutableArray array];
|
|
134
|
+
_dirtyFlags = ENRMDirtyNone;
|
|
135
|
+
[self configureSegmentViewRegistry];
|
|
136
|
+
|
|
137
|
+
_renderCoordinator =
|
|
138
|
+
[[ENRMAsyncRenderCoordinator alloc] initWithQueueLabel:"com.swmansion.enriched.markdown.container.render"];
|
|
139
|
+
|
|
140
|
+
_maxFontSizeMultiplier = 0;
|
|
141
|
+
_allowTrailingMargin = NO;
|
|
142
|
+
_selectable = YES;
|
|
143
|
+
_enableLinkPreview = YES;
|
|
144
|
+
_streamingAnimation = NO;
|
|
145
|
+
_tableStreamingMode = ENRMTableStreamingModeProgressive;
|
|
146
|
+
_selectionMenuConfig = (ENRMSelectionMenuConfig){.copyAsMarkdown = YES, .copyImageURL = YES};
|
|
147
|
+
_lineBreakStrategy = NSLineBreakStrategyNone;
|
|
148
|
+
_writingDirectionMode = ENRMWritingDirectionModeFirstStrong;
|
|
149
|
+
_resolvedLayoutDirection =
|
|
150
|
+
[[RCTI18nUtil sharedInstance] isRTL] ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight;
|
|
151
|
+
|
|
152
|
+
_fontScaleObserver = [[FontScaleObserver alloc] init];
|
|
153
|
+
__weak EnrichedMarkdown *weakSelf = self;
|
|
154
|
+
_fontScaleObserver.onChange = ^{
|
|
155
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
156
|
+
if (!strongSelf)
|
|
157
|
+
return;
|
|
158
|
+
if (strongSelf->_config != nil) {
|
|
159
|
+
[strongSelf->_config setFontScaleMultiplier:strongSelf->_fontScaleObserver.effectiveFontScale];
|
|
160
|
+
}
|
|
161
|
+
if (strongSelf->_cachedMarkdown != nil && strongSelf->_cachedMarkdown.length > 0) {
|
|
162
|
+
strongSelf->_dirtyFlags |= ENRMDirtyRecreateSegments | ENRMDirtyForceHeight;
|
|
163
|
+
[strongSelf renderMarkdownContent:strongSelf->_cachedMarkdown];
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return self;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
- (void)configureSegmentViewRegistry
|
|
171
|
+
{
|
|
172
|
+
__weak EnrichedMarkdown *weakSelf = self;
|
|
173
|
+
NSMutableArray<ENRMSegmentViewHandler *> *handlers = [NSMutableArray array];
|
|
174
|
+
|
|
175
|
+
[handlers addObject:[ENRMSegmentViewHandler handlerWithKind:ENRMSegmentKindText
|
|
176
|
+
matchesView:^BOOL(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
177
|
+
return [view isKindOfClass:[EnrichedMarkdownInternalText class]];
|
|
178
|
+
}
|
|
179
|
+
createView:^RCTUIView *(ENRMRenderedSegment *segment) {
|
|
180
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
181
|
+
if (!strongSelf) {
|
|
182
|
+
return [[RCTUIView alloc] init];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
EnrichedMarkdownInternalText *view =
|
|
186
|
+
[strongSelf createTextViewForRenderedSegment:segment.textResult];
|
|
187
|
+
[strongSelf animateTextView:view fromTailStart:0];
|
|
188
|
+
return view;
|
|
189
|
+
}
|
|
190
|
+
updateView:^(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
191
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
192
|
+
if (strongSelf) {
|
|
193
|
+
[strongSelf updateTextView:(EnrichedMarkdownInternalText *)view
|
|
194
|
+
withRenderedSegment:segment.textResult];
|
|
195
|
+
}
|
|
196
|
+
}]];
|
|
197
|
+
|
|
198
|
+
[handlers addObject:[ENRMSegmentViewHandler handlerWithKind:ENRMSegmentKindTable
|
|
199
|
+
matchesView:^BOOL(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
200
|
+
return [view isKindOfClass:[TableContainerView class]];
|
|
201
|
+
}
|
|
202
|
+
createView:^RCTUIView *(ENRMRenderedSegment *segment) {
|
|
203
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
204
|
+
if (!strongSelf) {
|
|
205
|
+
return [[RCTUIView alloc] init];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
TableContainerView *view = [strongSelf createTableViewForSegment:segment.tableSegment];
|
|
209
|
+
[strongSelf animateBlockViewIfNeeded:view];
|
|
210
|
+
return view;
|
|
211
|
+
}
|
|
212
|
+
updateView:^(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
213
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
214
|
+
if (strongSelf) {
|
|
215
|
+
[strongSelf updateTableView:(TableContainerView *)view withSegment:segment.tableSegment];
|
|
216
|
+
}
|
|
217
|
+
}]];
|
|
218
|
+
|
|
219
|
+
#if ENRICHED_MARKDOWN_MATH
|
|
220
|
+
[handlers addObject:[ENRMSegmentViewHandler handlerWithKind:ENRMSegmentKindMath
|
|
221
|
+
matchesView:^BOOL(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
222
|
+
return [view isKindOfClass:[ENRMMathContainerView class]];
|
|
223
|
+
}
|
|
224
|
+
createView:^RCTUIView *(ENRMRenderedSegment *segment) {
|
|
225
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
226
|
+
if (!strongSelf) {
|
|
227
|
+
return [[RCTUIView alloc] init];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
ENRMMathContainerView *view =
|
|
231
|
+
[strongSelf createMathViewForSegment:(ENRMMathSegment *)segment.mathSegment];
|
|
232
|
+
[strongSelf animateBlockViewIfNeeded:view];
|
|
233
|
+
return view;
|
|
234
|
+
}
|
|
235
|
+
updateView:^(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
236
|
+
[(ENRMMathContainerView *)view applyLatex:((ENRMMathSegment *)segment.mathSegment).latex];
|
|
237
|
+
}]];
|
|
238
|
+
#endif
|
|
239
|
+
|
|
240
|
+
_segmentViewRegistry = [[ENRMSegmentViewRegistry alloc] initWithHandlers:handlers];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
- (CGSize)computeSegmentLayoutForWidth:(CGFloat)width applyFrames:(BOOL)applyFrames
|
|
244
|
+
{
|
|
245
|
+
if (_segmentViews.count == 0)
|
|
246
|
+
return CGSizeZero;
|
|
247
|
+
|
|
248
|
+
__block CGFloat yOffset = 0.0;
|
|
249
|
+
__block CGFloat maxContentWidth = 0.0;
|
|
250
|
+
const NSUInteger lastIndex = _segmentViews.count - 1;
|
|
251
|
+
|
|
252
|
+
[_segmentViews enumerateObjectsUsingBlock:^(RCTUIView *segment, NSUInteger i, BOOL *stop) {
|
|
253
|
+
const BOOL isLast = (i == lastIndex);
|
|
254
|
+
const BOOL shouldAddBottomMargin = (!isLast || _allowTrailingMargin);
|
|
255
|
+
|
|
256
|
+
CGFloat segmentHeight = 0;
|
|
257
|
+
|
|
258
|
+
if ([segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
259
|
+
EnrichedMarkdownInternalText *textView = (EnrichedMarkdownInternalText *)segment;
|
|
260
|
+
textView.allowTrailingMargin = shouldAddBottomMargin;
|
|
261
|
+
CGSize textSize = [textView measureSize:width];
|
|
262
|
+
segmentHeight = textSize.height;
|
|
263
|
+
maxContentWidth = MAX(maxContentWidth, textSize.width);
|
|
264
|
+
|
|
265
|
+
} else if ([segment isKindOfClass:[TableContainerView class]]) {
|
|
266
|
+
yOffset += _config.tableMarginTop;
|
|
267
|
+
segmentHeight = [(TableContainerView *)segment measureHeight:width];
|
|
268
|
+
maxContentWidth = width;
|
|
269
|
+
}
|
|
270
|
+
#if ENRICHED_MARKDOWN_MATH
|
|
271
|
+
else if ([segment isKindOfClass:[ENRMMathContainerView class]]) {
|
|
272
|
+
yOffset += _config.mathMarginTop;
|
|
273
|
+
segmentHeight = [(ENRMMathContainerView *)segment measureHeight:width];
|
|
274
|
+
maxContentWidth = width;
|
|
275
|
+
}
|
|
276
|
+
#endif
|
|
277
|
+
|
|
278
|
+
if (applyFrames) {
|
|
279
|
+
CGRect segmentFrame = CGRectMake(0, yOffset, width, segmentHeight);
|
|
280
|
+
segment.frame = segmentFrame;
|
|
281
|
+
#if TARGET_OS_OSX
|
|
282
|
+
if ([segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
283
|
+
EnrichedMarkdownInternalText *textSeg = (EnrichedMarkdownInternalText *)segment;
|
|
284
|
+
textSeg.textView.frame = segment.bounds;
|
|
285
|
+
textSeg.textView.textContainer.size = CGSizeMake(width, CGFLOAT_MAX);
|
|
286
|
+
[textSeg.textView.layoutManager ensureLayoutForTextContainer:textSeg.textView.textContainer];
|
|
287
|
+
ENRMSetNeedsDisplay(textSeg.textView);
|
|
288
|
+
}
|
|
289
|
+
#endif
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
yOffset += segmentHeight;
|
|
293
|
+
|
|
294
|
+
if ([segment isKindOfClass:[TableContainerView class]] && shouldAddBottomMargin) {
|
|
295
|
+
yOffset += _config.tableMarginBottom;
|
|
296
|
+
}
|
|
297
|
+
#if ENRICHED_MARKDOWN_MATH
|
|
298
|
+
else if ([segment isKindOfClass:[ENRMMathContainerView class]] && shouldAddBottomMargin) {
|
|
299
|
+
yOffset += _config.mathMarginBottom;
|
|
300
|
+
}
|
|
301
|
+
#endif
|
|
302
|
+
}];
|
|
303
|
+
|
|
304
|
+
return CGSizeMake(maxContentWidth, yOffset);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
- (CGSize)measureSize:(CGFloat)maxWidth
|
|
308
|
+
{
|
|
309
|
+
CGFloat defaultHeight = UIFontLineHeight([UIFont systemFontOfSize:16.0]);
|
|
310
|
+
CGSize contentSize = [self computeSegmentLayoutForWidth:maxWidth applyFrames:NO];
|
|
311
|
+
if (contentSize.height == 0)
|
|
312
|
+
return CGSizeMake(maxWidth, defaultHeight);
|
|
313
|
+
|
|
314
|
+
CGFloat scale = RCTScreenScale();
|
|
315
|
+
CGFloat measuredWidth = MIN(ceil(contentSize.width * scale) / scale, maxWidth);
|
|
316
|
+
CGFloat measuredHeight = ceil(contentSize.height * scale) / scale;
|
|
317
|
+
return CGSizeMake(measuredWidth, measuredHeight);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
- (BOOL)hasRenderedMarkdown:(NSString *)markdown
|
|
321
|
+
{
|
|
322
|
+
return _renderedMarkdown != nil && [_renderedMarkdown isEqualToString:markdown];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
- (BOOL)hasRenderedWithStyleFingerprint:(size_t)fingerprint
|
|
326
|
+
{
|
|
327
|
+
return _renderedStyleFingerprint == fingerprint;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
- (BOOL)renderedSegmentsChangeTopology:(NSArray<ENRMRenderedSegment *> *)renderedSegments
|
|
331
|
+
{
|
|
332
|
+
if (renderedSegments.count != _segmentViews.count) {
|
|
333
|
+
return YES;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
for (NSUInteger index = 0; index < renderedSegments.count; index++) {
|
|
337
|
+
if (![_segmentViewRegistry view:_segmentViews[index] matchesSegment:renderedSegments[index]]) {
|
|
338
|
+
return YES;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return NO;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
- (void)updateState:(const facebook::react::State::Shared &)state
|
|
346
|
+
oldState:(const facebook::react::State::Shared &)oldState
|
|
347
|
+
{
|
|
348
|
+
_state = std::static_pointer_cast<const EnrichedMarkdownShadowNode::ConcreteState>(state);
|
|
349
|
+
|
|
350
|
+
if (oldState == nullptr) {
|
|
351
|
+
[self requestHeightUpdate];
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/// Yoga-resolved direction inherited from any ancestor `direction` style.
|
|
356
|
+
/// In FirstStrong mode this feeds the neutral-paragraph fallback, so a change
|
|
357
|
+
/// requires segment recreation.
|
|
358
|
+
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
|
|
359
|
+
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
360
|
+
{
|
|
361
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
362
|
+
|
|
363
|
+
NSWritingDirection resolved = _resolvedLayoutDirection;
|
|
364
|
+
if (layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
|
|
365
|
+
resolved = NSWritingDirectionRightToLeft;
|
|
366
|
+
} else if (layoutMetrics.layoutDirection == LayoutDirection::LeftToRight) {
|
|
367
|
+
resolved = NSWritingDirectionLeftToRight;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (resolved != _resolvedLayoutDirection) {
|
|
371
|
+
_resolvedLayoutDirection = resolved;
|
|
372
|
+
[self pushWritingDirectionToTableSegments];
|
|
373
|
+
if (_writingDirectionMode == ENRMWritingDirectionModeFirstStrong && _cachedMarkdown.length > 0) {
|
|
374
|
+
_dirtyFlags |= ENRMDirtyRecreateSegments | ENRMDirtyForceHeight;
|
|
375
|
+
[self renderMarkdownContent:_cachedMarkdown];
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
- (void)pushWritingDirectionToTableSegments
|
|
381
|
+
{
|
|
382
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
383
|
+
if ([segment isKindOfClass:[TableContainerView class]]) {
|
|
384
|
+
TableContainerView *tableView = (TableContainerView *)segment;
|
|
385
|
+
tableView.writingDirectionMode = _writingDirectionMode;
|
|
386
|
+
tableView.resolvedLayoutDirection = _resolvedLayoutDirection;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
- (void)requestHeightUpdate
|
|
392
|
+
{
|
|
393
|
+
ENRMRequestHeightUpdate<EnrichedMarkdownState>(_state, _heightUpdateCounter, self);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
- (void)renderMarkdownContent:(NSString *)markdownString
|
|
397
|
+
{
|
|
398
|
+
if (_renderCoordinator.blockAsyncRender)
|
|
399
|
+
return;
|
|
400
|
+
|
|
401
|
+
_cachedMarkdown = [markdownString copy];
|
|
402
|
+
|
|
403
|
+
StyleConfig *config = [_config copy];
|
|
404
|
+
ENRMMarkdownParser *parser = _parser;
|
|
405
|
+
ENRMMd4cFlags *md4cFlags = [_md4cFlags copy];
|
|
406
|
+
|
|
407
|
+
BOOL allowFontScaling = _fontScaleObserver.allowFontScaling;
|
|
408
|
+
CGFloat maxFontSizeMultiplier = _maxFontSizeMultiplier;
|
|
409
|
+
BOOL allowTrailingMargin = _allowTrailingMargin;
|
|
410
|
+
BOOL streamingAnimation = _streamingAnimation;
|
|
411
|
+
ENRMTableStreamingMode tableStreamingMode = _tableStreamingMode;
|
|
412
|
+
NSLineBreakStrategy lineBreakStrategy = _lineBreakStrategy;
|
|
413
|
+
ENRMWritingDirectionMode writingDirectionMode = _writingDirectionMode;
|
|
414
|
+
NSWritingDirection resolvedLayoutDirection = _resolvedLayoutDirection;
|
|
415
|
+
|
|
416
|
+
__block NSArray<ENRMRenderedSegment *> *renderedSegments = nil;
|
|
417
|
+
__block NSString *renderableMarkdown = nil;
|
|
418
|
+
|
|
419
|
+
[_renderCoordinator
|
|
420
|
+
scheduleRender:^BOOL {
|
|
421
|
+
renderableMarkdown = streamingAnimation ? ENRMRenderableMarkdownForStreaming(markdownString, tableStreamingMode)
|
|
422
|
+
: markdownString;
|
|
423
|
+
|
|
424
|
+
if (renderableMarkdown.length == 0) {
|
|
425
|
+
renderedSegments = @[];
|
|
426
|
+
return YES;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
MarkdownASTNode *ast = [parser parseMarkdown:renderableMarkdown flags:md4cFlags];
|
|
430
|
+
if (!ast)
|
|
431
|
+
return NO;
|
|
432
|
+
|
|
433
|
+
renderedSegments = ENRMRenderSegmentsFromAST(ast, config, allowTrailingMargin, allowFontScaling,
|
|
434
|
+
maxFontSizeMultiplier, lineBreakStrategy);
|
|
435
|
+
for (ENRMRenderedSegment *segment in renderedSegments) {
|
|
436
|
+
if (segment.kind == ENRMSegmentKindText && segment.textResult) {
|
|
437
|
+
ENRMApplyWritingDirectionMode(segment.textResult.attributedText, writingDirectionMode,
|
|
438
|
+
resolvedLayoutDirection);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return YES;
|
|
442
|
+
}
|
|
443
|
+
apply:^{
|
|
444
|
+
self->_renderedStyleFingerprint = self->_pendingStyleFingerprint;
|
|
445
|
+
[self applyRenderedSegments:renderedSegments renderedMarkdown:renderableMarkdown];
|
|
446
|
+
}];
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
- (NSArray *)parseAndRenderSegments:(NSString *)markdownString
|
|
450
|
+
{
|
|
451
|
+
MarkdownASTNode *ast = [_parser parseMarkdown:markdownString flags:_md4cFlags];
|
|
452
|
+
if (!ast) {
|
|
453
|
+
return nil;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
NSArray<ENRMRenderedSegment *> *segments =
|
|
457
|
+
ENRMRenderSegmentsFromAST(ast, _config, _allowTrailingMargin, _fontScaleObserver.allowFontScaling,
|
|
458
|
+
_maxFontSizeMultiplier, _lineBreakStrategy);
|
|
459
|
+
for (ENRMRenderedSegment *segment in segments) {
|
|
460
|
+
if (segment.kind == ENRMSegmentKindText && segment.textResult) {
|
|
461
|
+
ENRMApplyWritingDirectionMode(segment.textResult.attributedText, _writingDirectionMode, _resolvedLayoutDirection);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return segments;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/// Synchronous rendering for mock view measurement (no UI updates needed).
|
|
468
|
+
- (void)renderMarkdownSynchronously:(NSString *)markdownString
|
|
469
|
+
{
|
|
470
|
+
if (!markdownString || markdownString.length == 0) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
for (RCTUIView *view in _segmentViews) {
|
|
475
|
+
[view removeFromSuperview];
|
|
476
|
+
}
|
|
477
|
+
[_segmentViews removeAllObjects];
|
|
478
|
+
[_segmentSignatures removeAllObjects];
|
|
479
|
+
|
|
480
|
+
_renderCoordinator.blockAsyncRender = YES;
|
|
481
|
+
_cachedMarkdown = [markdownString copy];
|
|
482
|
+
NSString *renderableMarkdown =
|
|
483
|
+
_streamingAnimation ? ENRMRenderableMarkdownForStreaming(markdownString, _tableStreamingMode) : markdownString;
|
|
484
|
+
_renderedMarkdown = [renderableMarkdown copy];
|
|
485
|
+
_renderedStyleFingerprint = _pendingStyleFingerprint;
|
|
486
|
+
|
|
487
|
+
if (renderableMarkdown.length == 0) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
NSArray *renderedSegments = [self parseAndRenderSegments:renderableMarkdown];
|
|
492
|
+
if (!renderedSegments) {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
for (ENRMRenderedSegment *segment in renderedSegments) {
|
|
497
|
+
RCTUIView *view = [_segmentViewRegistry createViewForSegment:segment];
|
|
498
|
+
[_segmentViews addObject:view];
|
|
499
|
+
[_segmentSignatures addObject:@(segment.signature)];
|
|
500
|
+
[self addSubview:view];
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
- (void)applyRenderedSegments:(NSArray *)renderedSegments renderedMarkdown:(NSString *)renderedMarkdown
|
|
505
|
+
{
|
|
506
|
+
_renderedMarkdown = [renderedMarkdown copy];
|
|
507
|
+
BOOL segmentTopologyChanged = _streamingAnimation && [self renderedSegmentsChangeTopology:renderedSegments];
|
|
508
|
+
|
|
509
|
+
ENRMSegmentReconciliationResult *result = [ENRMSegmentReconciler reconcileCurrentViews:_segmentViews
|
|
510
|
+
currentSignatures:_segmentSignatures
|
|
511
|
+
renderedSegments:renderedSegments
|
|
512
|
+
reset:(_dirtyFlags & ENRMDirtyRecreateSegments) != 0
|
|
513
|
+
createView:^RCTUIView *(ENRMRenderedSegment *segment) {
|
|
514
|
+
return [self->_segmentViewRegistry createViewForSegment:segment];
|
|
515
|
+
}
|
|
516
|
+
updateView:^(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
517
|
+
[self->_segmentViewRegistry updateView:view withSegment:segment];
|
|
518
|
+
}
|
|
519
|
+
attachView:^(RCTUIView *view) { [self addSubview:view]; }
|
|
520
|
+
removeView:^(RCTUIView *view) { [view removeFromSuperview]; }
|
|
521
|
+
matchesKind:^BOOL(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
522
|
+
return [self->_segmentViewRegistry view:view matchesSegment:segment];
|
|
523
|
+
}];
|
|
524
|
+
BOOL forceHeightUpdate = (_dirtyFlags & ENRMDirtyForceHeight) != 0;
|
|
525
|
+
_dirtyFlags = ENRMDirtyNone;
|
|
526
|
+
|
|
527
|
+
_segmentViews = result.views;
|
|
528
|
+
_segmentSignatures = result.signatures;
|
|
529
|
+
|
|
530
|
+
if (self.bounds.size.width > 0) {
|
|
531
|
+
[self setNeedsLayout];
|
|
532
|
+
|
|
533
|
+
if (forceHeightUpdate || segmentTopologyChanged) {
|
|
534
|
+
[self computeSegmentLayoutForWidth:self.bounds.size.width applyFrames:YES];
|
|
535
|
+
[self layoutIfNeeded];
|
|
536
|
+
[self requestHeightUpdate];
|
|
537
|
+
} else {
|
|
538
|
+
CGSize measured = [self measureSize:self.bounds.size.width];
|
|
539
|
+
if (needsHeightUpdate(measured, self.bounds)) {
|
|
540
|
+
[self requestHeightUpdate];
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
- (void)configureTextView:(EnrichedMarkdownInternalText *)view withRenderedSegment:(ENRMRenderResult *)segment
|
|
547
|
+
{
|
|
548
|
+
view.spoilerOverlay = _spoilerOverlay;
|
|
549
|
+
view.allowTrailingMargin = _allowTrailingMargin;
|
|
550
|
+
view.lastElementMarginBottom = segment.lastElementMarginBottom;
|
|
551
|
+
view.accessibilityInfo = segment.accessibilityInfo;
|
|
552
|
+
view.textView.selectable = _selectable;
|
|
553
|
+
[view applyAttributedText:segment.attributedText context:segment.context];
|
|
554
|
+
|
|
555
|
+
const auto &selectionProps = *std::static_pointer_cast<EnrichedMarkdownProps const>(self->_props);
|
|
556
|
+
ENRMApplySelectionColor(view.textView, selectionProps.selectionColor);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
- (EnrichedMarkdownInternalText *)createTextViewForRenderedSegment:(ENRMRenderResult *)segment
|
|
560
|
+
{
|
|
561
|
+
EnrichedMarkdownInternalText *view = [[EnrichedMarkdownInternalText alloc] initWithConfig:_config];
|
|
562
|
+
[self configureTextView:view withRenderedSegment:segment];
|
|
563
|
+
|
|
564
|
+
ENRMTapRecognizer *tapRecognizer = [[ENRMTapRecognizer alloc] initWithTarget:self action:@selector(textTapped:)];
|
|
565
|
+
[view.textView addGestureRecognizer:tapRecognizer];
|
|
566
|
+
|
|
567
|
+
#if !TARGET_OS_OSX
|
|
568
|
+
view.textView.delegate = self;
|
|
569
|
+
#else
|
|
570
|
+
__weak EnrichedMarkdown *weakSelf = self;
|
|
571
|
+
[view setContextMenuProvider:^NSMenu *_Nullable(NSMenu *baseMenu, NSTextView *textView) {
|
|
572
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
573
|
+
if (!strongSelf) {
|
|
574
|
+
return baseMenu;
|
|
575
|
+
}
|
|
576
|
+
NSString *segmentMarkdown = extractMarkdownFromAttributedString(textView.textStorage, textView.selectedRange);
|
|
577
|
+
NSArray<NSMenuItem *> *customItems = ENRMBuildContextMenuItems(
|
|
578
|
+
strongSelf->_contextMenuItemTexts, strongSelf->_contextMenuItemIcons, textView,
|
|
579
|
+
^(NSString *itemText, NSString *selectedText, NSUInteger selectionStart, NSUInteger selectionEnd) {
|
|
580
|
+
[strongSelf emitContextMenuItemPress:itemText
|
|
581
|
+
selectedText:selectedText
|
|
582
|
+
selectionStart:selectionStart
|
|
583
|
+
selectionEnd:selectionEnd];
|
|
584
|
+
});
|
|
585
|
+
return buildEditMenuForSelection(textView.textStorage, textView.selectedRange, segmentMarkdown, strongSelf->_config,
|
|
586
|
+
@[ baseMenu ], customItems, strongSelf -> _selectionMenuConfig);
|
|
587
|
+
}];
|
|
588
|
+
#endif
|
|
589
|
+
|
|
590
|
+
return view;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
- (TableContainerView *)createTableViewForSegment:(ENRMTableSegment *)tableSegment
|
|
594
|
+
{
|
|
595
|
+
TableContainerView *tableView = [[TableContainerView alloc] initWithConfig:_config];
|
|
596
|
+
|
|
597
|
+
tableView.allowFontScaling = _fontScaleObserver.allowFontScaling;
|
|
598
|
+
tableView.maxFontSizeMultiplier = _maxFontSizeMultiplier;
|
|
599
|
+
tableView.enableLinkPreview = _enableLinkPreview;
|
|
600
|
+
tableView.writingDirectionMode = _writingDirectionMode;
|
|
601
|
+
tableView.resolvedLayoutDirection = _resolvedLayoutDirection;
|
|
602
|
+
|
|
603
|
+
__weak EnrichedMarkdown *weakSelf = self;
|
|
604
|
+
|
|
605
|
+
tableView.onLinkPress = ^(NSString *url) {
|
|
606
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
607
|
+
if (strongSelf && url)
|
|
608
|
+
[strongSelf emitLinkPress:url];
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
tableView.onLinkLongPress = ^(NSString *url) {
|
|
612
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
613
|
+
if (strongSelf && url)
|
|
614
|
+
[strongSelf emitLinkLongPress:url];
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
[tableView applyTableNode:tableSegment.tableNode];
|
|
618
|
+
|
|
619
|
+
return tableView;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
- (void)updateTableView:(TableContainerView *)view withSegment:(ENRMTableSegment *)tableSegment
|
|
623
|
+
{
|
|
624
|
+
view.writingDirectionMode = _writingDirectionMode;
|
|
625
|
+
view.resolvedLayoutDirection = _resolvedLayoutDirection;
|
|
626
|
+
NSUInteger previousRowCount = view.rowCount;
|
|
627
|
+
[view applyTableNode:tableSegment.tableNode];
|
|
628
|
+
|
|
629
|
+
if (_streamingAnimation && !ENRMShouldReduceMotion()) {
|
|
630
|
+
[view animateNewRowsFromPreviousCount:previousRowCount duration:0.20];
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
#if ENRICHED_MARKDOWN_MATH
|
|
635
|
+
- (ENRMMathContainerView *)createMathViewForSegment:(ENRMMathSegment *)mathSegment
|
|
636
|
+
{
|
|
637
|
+
ENRMMathContainerView *mathView = [[ENRMMathContainerView alloc] initWithConfig:_config];
|
|
638
|
+
[mathView applyLatex:mathSegment.latex];
|
|
639
|
+
return mathView;
|
|
640
|
+
}
|
|
641
|
+
#endif
|
|
642
|
+
|
|
643
|
+
- (void)animateBlockViewIfNeeded:(RCTUIView *)view
|
|
644
|
+
{
|
|
645
|
+
if (!_streamingAnimation)
|
|
646
|
+
return;
|
|
647
|
+
|
|
648
|
+
#if !TARGET_OS_OSX
|
|
649
|
+
if (ENRMShouldReduceMotion()) {
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
view.alpha = 0.0;
|
|
653
|
+
[UIView animateWithDuration:0.20 animations:^{ view.alpha = 1.0; }];
|
|
654
|
+
#endif
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
- (void)animateTextView:(EnrichedMarkdownInternalText *)view fromTailStart:(NSUInteger)tailStart
|
|
658
|
+
{
|
|
659
|
+
if (!_streamingAnimation)
|
|
660
|
+
return;
|
|
661
|
+
|
|
662
|
+
ENRMTailFadeInAnimator *animator = objc_getAssociatedObject(view.textView, &kENRMSegmentFadeAnimatorKey);
|
|
663
|
+
if (!animator) {
|
|
664
|
+
animator = [[ENRMTailFadeInAnimator alloc] initWithTextView:view.textView];
|
|
665
|
+
objc_setAssociatedObject(view.textView, &kENRMSegmentFadeAnimatorKey, animator, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
[animator animateFrom:tailStart to:ENRMGetAttributedText(view.textView).length];
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
- (void)updateTextView:(EnrichedMarkdownInternalText *)view withRenderedSegment:(ENRMRenderResult *)segment
|
|
672
|
+
{
|
|
673
|
+
NSUInteger tailStart = ENRMGetAttributedText(view.textView).length;
|
|
674
|
+
[self configureTextView:view withRenderedSegment:segment];
|
|
675
|
+
[self animateTextView:view fromTailStart:tailStart];
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
- (void)layoutSubviews
|
|
679
|
+
{
|
|
680
|
+
[super layoutSubviews];
|
|
681
|
+
[self computeSegmentLayoutForWidth:self.bounds.size.width applyFrames:YES];
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
685
|
+
{
|
|
686
|
+
const auto &oldViewProps = *std::static_pointer_cast<EnrichedMarkdownProps const>(_props);
|
|
687
|
+
const auto &newViewProps = *std::static_pointer_cast<EnrichedMarkdownProps const>(props);
|
|
688
|
+
|
|
689
|
+
BOOL markdownChanged = oldViewProps.markdown != newViewProps.markdown;
|
|
690
|
+
if (markdownChanged) {
|
|
691
|
+
_dirtyFlags |= ENRMDirtyRender;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
if (_config == nil) {
|
|
695
|
+
_config = [[StyleConfig alloc] init];
|
|
696
|
+
[_config setFontScaleMultiplier:_fontScaleObserver.effectiveFontScale];
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
if (applyMarkdownStyleToConfig(_config, newViewProps.markdownStyle, oldViewProps.markdownStyle)) {
|
|
700
|
+
[ENRMImageAttachment clearAttachmentRegistry];
|
|
701
|
+
_dirtyFlags |= ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
702
|
+
if (!markdownChanged) {
|
|
703
|
+
_dirtyFlags |= ENRMDirtyRecreateSegments;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
_selectable = newViewProps.selectable;
|
|
708
|
+
|
|
709
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
710
|
+
if ([segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
711
|
+
EnrichedMarkdownInternalText *textSegment = (EnrichedMarkdownInternalText *)segment;
|
|
712
|
+
if (textSegment.textView.selectable != newViewProps.selectable) {
|
|
713
|
+
textSegment.textView.selectable = newViewProps.selectable;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
if (newViewProps.allowFontScaling != oldViewProps.allowFontScaling) {
|
|
719
|
+
_fontScaleObserver.allowFontScaling = newViewProps.allowFontScaling;
|
|
720
|
+
if (_config != nil) {
|
|
721
|
+
[_config setFontScaleMultiplier:_fontScaleObserver.effectiveFontScale];
|
|
722
|
+
}
|
|
723
|
+
_dirtyFlags |= ENRMDirtyRecreateSegments | ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
if (newViewProps.maxFontSizeMultiplier != oldViewProps.maxFontSizeMultiplier) {
|
|
727
|
+
_maxFontSizeMultiplier = newViewProps.maxFontSizeMultiplier;
|
|
728
|
+
if (_config != nil) {
|
|
729
|
+
[_config setMaxFontSizeMultiplier:_maxFontSizeMultiplier];
|
|
730
|
+
}
|
|
731
|
+
_dirtyFlags |= ENRMDirtyRecreateSegments | ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
if (newViewProps.allowTrailingMargin != oldViewProps.allowTrailingMargin) {
|
|
735
|
+
_allowTrailingMargin = newViewProps.allowTrailingMargin;
|
|
736
|
+
_dirtyFlags |= ENRMDirtyRecreateSegments | ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
if (newViewProps.md4cFlags.underline != oldViewProps.md4cFlags.underline) {
|
|
740
|
+
_md4cFlags.underline = newViewProps.md4cFlags.underline;
|
|
741
|
+
_dirtyFlags |= ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
742
|
+
}
|
|
743
|
+
if (newViewProps.md4cFlags.superscript != oldViewProps.md4cFlags.superscript) {
|
|
744
|
+
_md4cFlags.superscript = newViewProps.md4cFlags.superscript;
|
|
745
|
+
_dirtyFlags |= ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
746
|
+
}
|
|
747
|
+
if (newViewProps.md4cFlags.subscript != oldViewProps.md4cFlags.subscript) {
|
|
748
|
+
_md4cFlags.subscript = newViewProps.md4cFlags.subscript;
|
|
749
|
+
_dirtyFlags |= ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
750
|
+
}
|
|
751
|
+
if (newViewProps.md4cFlags.latexMath != oldViewProps.md4cFlags.latexMath) {
|
|
752
|
+
_md4cFlags.latexMath = newViewProps.md4cFlags.latexMath;
|
|
753
|
+
_dirtyFlags |= ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
754
|
+
}
|
|
755
|
+
if (newViewProps.md4cFlags.highlight != oldViewProps.md4cFlags.highlight) {
|
|
756
|
+
_md4cFlags.highlight = newViewProps.md4cFlags.highlight;
|
|
757
|
+
_dirtyFlags |= ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
_enableLinkPreview = newViewProps.enableLinkPreview;
|
|
761
|
+
|
|
762
|
+
if (newViewProps.streamingAnimation != oldViewProps.streamingAnimation) {
|
|
763
|
+
_streamingAnimation = newViewProps.streamingAnimation;
|
|
764
|
+
_dirtyFlags |= ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
765
|
+
if (!_streamingAnimation) {
|
|
766
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
767
|
+
if ([segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
768
|
+
ENRMTailFadeInAnimator *animator = objc_getAssociatedObject(
|
|
769
|
+
((EnrichedMarkdownInternalText *)segment).textView, &kENRMSegmentFadeAnimatorKey);
|
|
770
|
+
[animator cancel];
|
|
771
|
+
objc_setAssociatedObject(((EnrichedMarkdownInternalText *)segment).textView, &kENRMSegmentFadeAnimatorKey,
|
|
772
|
+
nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
if (newViewProps.streamingConfig.tableMode != oldViewProps.streamingConfig.tableMode) {
|
|
779
|
+
NSString *tableModeStr = [[NSString alloc] initWithUTF8String:newViewProps.streamingConfig.tableMode.c_str()];
|
|
780
|
+
_tableStreamingMode =
|
|
781
|
+
[tableModeStr isEqualToString:@"hidden"] ? ENRMTableStreamingModeHidden : ENRMTableStreamingModeProgressive;
|
|
782
|
+
_dirtyFlags |= ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
if (ENRMContextMenuItemsChanged(oldViewProps.contextMenuItems, newViewProps.contextMenuItems)) {
|
|
786
|
+
_contextMenuItemTexts = ENRMContextMenuTextsFromItems(newViewProps.contextMenuItems);
|
|
787
|
+
_contextMenuItemIcons = ENRMContextMenuIconsFromItems(newViewProps.contextMenuItems);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
_selectionMenuConfig = (ENRMSelectionMenuConfig){
|
|
791
|
+
.copyAsMarkdown = newViewProps.selectionMenuConfig.copyAsMarkdown,
|
|
792
|
+
.copyImageURL = newViewProps.selectionMenuConfig.copyImageUrl,
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
if (newViewProps.spoilerOverlay != oldViewProps.spoilerOverlay) {
|
|
796
|
+
NSString *modeStr = [[NSString alloc] initWithUTF8String:newViewProps.spoilerOverlay.c_str()];
|
|
797
|
+
_spoilerOverlay = ENRMSpoilerOverlayFromString(modeStr);
|
|
798
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
799
|
+
if ([segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
800
|
+
((EnrichedMarkdownInternalText *)segment).spoilerOverlay = _spoilerOverlay;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
if (newViewProps.selectionColor != oldViewProps.selectionColor) {
|
|
806
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
807
|
+
if ([segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
808
|
+
ENRMPlatformTextView *tv = ((EnrichedMarkdownInternalText *)segment).textView;
|
|
809
|
+
ENRMApplySelectionColor(tv, newViewProps.selectionColor);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
if (newViewProps.lineBreakStrategyIOS != oldViewProps.lineBreakStrategyIOS) {
|
|
815
|
+
NSString *strategy = [[NSString alloc] initWithUTF8String:newViewProps.lineBreakStrategyIOS.c_str()];
|
|
816
|
+
_lineBreakStrategy = ENRMResolveLineBreakStrategy(strategy);
|
|
817
|
+
_dirtyFlags |= ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
if (newViewProps.writingDirection != oldViewProps.writingDirection) {
|
|
821
|
+
NSString *value = [[NSString alloc] initWithUTF8String:newViewProps.writingDirection.c_str()];
|
|
822
|
+
_writingDirectionMode = ENRMResolveWritingDirectionMode(value);
|
|
823
|
+
_dirtyFlags |= ENRMDirtyRecreateSegments | ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
824
|
+
[self pushWritingDirectionToTableSegments];
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
if (_dirtyFlags & ENRMDirtyRender) {
|
|
828
|
+
_pendingStyleFingerprint =
|
|
829
|
+
computeStyleFingerprint(newViewProps.markdownStyle) ^ std::hash<bool>{}(newViewProps.allowTrailingMargin);
|
|
830
|
+
NSString *markdownString = [[NSString alloc] initWithUTF8String:newViewProps.markdown.c_str()];
|
|
831
|
+
[self renderMarkdownContent:markdownString];
|
|
832
|
+
_dirtyFlags &= ~ENRMDirtyRender;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
[super updateProps:props oldProps:oldProps];
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
- (void)didMoveToWindow
|
|
839
|
+
{
|
|
840
|
+
[super didMoveToWindow];
|
|
841
|
+
|
|
842
|
+
if (self.window && _renderedMarkdown != nil) {
|
|
843
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
844
|
+
if ([segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
845
|
+
EnrichedMarkdownInternalText *textSegment = (EnrichedMarkdownInternalText *)segment;
|
|
846
|
+
ENRMRefreshTextViewAfterWindowAttach(textSegment.textView, textSegment.bounds);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
CGSize measured = [self measureSize:self.bounds.size.width];
|
|
851
|
+
if (needsHeightUpdate(measured, self.bounds)) {
|
|
852
|
+
[self requestHeightUpdate];
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
- (void)prepareForRecycle
|
|
858
|
+
{
|
|
859
|
+
_props = std::make_shared<const EnrichedMarkdownProps>();
|
|
860
|
+
[_renderCoordinator invalidate];
|
|
861
|
+
|
|
862
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
863
|
+
if ([segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
864
|
+
EnrichedMarkdownInternalText *textSegment = (EnrichedMarkdownInternalText *)segment;
|
|
865
|
+
ENRMTailFadeInAnimator *animator = objc_getAssociatedObject(textSegment.textView, &kENRMSegmentFadeAnimatorKey);
|
|
866
|
+
[animator cancel];
|
|
867
|
+
objc_setAssociatedObject(textSegment.textView, &kENRMSegmentFadeAnimatorKey, nil,
|
|
868
|
+
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
869
|
+
}
|
|
870
|
+
[segment removeFromSuperview];
|
|
871
|
+
}
|
|
872
|
+
[_segmentViews removeAllObjects];
|
|
873
|
+
[_segmentSignatures removeAllObjects];
|
|
874
|
+
|
|
875
|
+
_cachedMarkdown = nil;
|
|
876
|
+
_renderedMarkdown = nil;
|
|
877
|
+
_streamingAnimation = NO;
|
|
878
|
+
_tableStreamingMode = ENRMTableStreamingModeProgressive;
|
|
879
|
+
_dirtyFlags = ENRMDirtyNone;
|
|
880
|
+
|
|
881
|
+
[super prepareForRecycle];
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
Class<RCTComponentViewProtocol> EnrichedMarkdownCls(void)
|
|
885
|
+
{
|
|
886
|
+
return EnrichedMarkdown.class;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
#if !TARGET_OS_OSX
|
|
890
|
+
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
|
|
891
|
+
{
|
|
892
|
+
if ([super pointInside:point withEvent:event]) {
|
|
893
|
+
return YES;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
897
|
+
if (CGRectContainsPoint(segment.frame, point)) {
|
|
898
|
+
return YES;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
return NO;
|
|
903
|
+
}
|
|
904
|
+
#endif
|
|
905
|
+
|
|
906
|
+
- (facebook::react::SharedTouchEventEmitter)touchEventEmitterAtPoint:(CGPoint)point
|
|
907
|
+
{
|
|
908
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
909
|
+
if ([segment isKindOfClass:[TableContainerView class]]) {
|
|
910
|
+
CGPoint segmentPoint = [self convertPoint:point toView:segment];
|
|
911
|
+
#if !TARGET_OS_OSX
|
|
912
|
+
if ([segment pointInside:segmentPoint withEvent:nil]) {
|
|
913
|
+
return nil;
|
|
914
|
+
}
|
|
915
|
+
#else
|
|
916
|
+
if (CGRectContainsPoint(segment.bounds, segmentPoint)) {
|
|
917
|
+
return nil;
|
|
918
|
+
}
|
|
919
|
+
#endif
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
if (![segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
923
|
+
continue;
|
|
924
|
+
}
|
|
925
|
+
EnrichedMarkdownInternalText *textSegment = (EnrichedMarkdownInternalText *)segment;
|
|
926
|
+
CGPoint segmentPoint = [self convertPoint:point toView:textSegment.textView];
|
|
927
|
+
#if !TARGET_OS_OSX
|
|
928
|
+
BOOL isInsideView = [textSegment.textView pointInside:segmentPoint withEvent:nil];
|
|
929
|
+
#else
|
|
930
|
+
BOOL isInsideView = CGRectContainsPoint(textSegment.textView.bounds, segmentPoint);
|
|
931
|
+
#endif
|
|
932
|
+
if (isInsideView) {
|
|
933
|
+
if (isPointOnInteractiveElement(textSegment.textView, segmentPoint)) {
|
|
934
|
+
return nil;
|
|
935
|
+
}
|
|
936
|
+
break;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
return [super touchEventEmitterAtPoint:point];
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
#if TARGET_OS_OSX
|
|
944
|
+
- (void)mouseDown:(NSEvent *)event
|
|
945
|
+
{
|
|
946
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
947
|
+
if (![segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
948
|
+
continue;
|
|
949
|
+
}
|
|
950
|
+
ENRMPlatformTextView *tv = ((EnrichedMarkdownInternalText *)segment).textView;
|
|
951
|
+
if (tv.selectedRange.length > 0) {
|
|
952
|
+
tv.selectedRange = NSMakeRange(0, 0);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
[super mouseDown:event];
|
|
956
|
+
}
|
|
957
|
+
#endif
|
|
958
|
+
|
|
959
|
+
- (void)emitLinkPress:(NSString *)url
|
|
960
|
+
{
|
|
961
|
+
auto emitter = std::static_pointer_cast<EnrichedMarkdownEventEmitter const>(_eventEmitter);
|
|
962
|
+
if (emitter)
|
|
963
|
+
emitter->onLinkPress({.url = std::string(url.UTF8String)});
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
- (void)emitLinkLongPress:(NSString *)url
|
|
967
|
+
{
|
|
968
|
+
auto emitter = std::static_pointer_cast<EnrichedMarkdownEventEmitter const>(_eventEmitter);
|
|
969
|
+
if (emitter)
|
|
970
|
+
emitter->onLinkLongPress({.url = std::string(url.UTF8String)});
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
- (void)emitTaskListItemPress:(NSInteger)index checked:(BOOL)checked text:(NSString *)text
|
|
974
|
+
{
|
|
975
|
+
auto emitter = std::static_pointer_cast<EnrichedMarkdownEventEmitter const>(_eventEmitter);
|
|
976
|
+
if (emitter)
|
|
977
|
+
emitter->onTaskListItemPress({.index = (int)index, .checked = checked, .text = std::string(text.UTF8String ?: "")});
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
- (void)emitContextMenuItemPress:(NSString *)itemText
|
|
981
|
+
selectedText:(NSString *)selectedText
|
|
982
|
+
selectionStart:(NSUInteger)selectionStart
|
|
983
|
+
selectionEnd:(NSUInteger)selectionEnd
|
|
984
|
+
{
|
|
985
|
+
auto emitter = std::static_pointer_cast<EnrichedMarkdownEventEmitter const>(_eventEmitter);
|
|
986
|
+
if (emitter)
|
|
987
|
+
emitter->onContextMenuItemPress({
|
|
988
|
+
.itemText = std::string(itemText.UTF8String),
|
|
989
|
+
.selectedText = std::string(selectedText.UTF8String),
|
|
990
|
+
.selectionStart = (int)selectionStart,
|
|
991
|
+
.selectionEnd = (int)selectionEnd,
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
- (void)textTapped:(ENRMTapRecognizer *)recognizer
|
|
996
|
+
{
|
|
997
|
+
ENRMPlatformTextView *textView = (ENRMPlatformTextView *)recognizer.view;
|
|
998
|
+
|
|
999
|
+
if (handleTaskListTapWithSharedLogic(
|
|
1000
|
+
textView, recognizer, &self->_cachedMarkdown, self->_config,
|
|
1001
|
+
^(NSInteger index, BOOL checked, NSString *itemText) {
|
|
1002
|
+
[self emitTaskListItemPress:index checked:checked text:itemText];
|
|
1003
|
+
},
|
|
1004
|
+
^(NSString *updatedMarkdown) { [self renderMarkdownContent:updatedMarkdown]; })) {
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
1009
|
+
if ([segment conformsToProtocol:@protocol(ENRMSpoilerCapable)]) {
|
|
1010
|
+
id<ENRMSpoilerCapable> spoilerSegment = (id<ENRMSpoilerCapable>)segment;
|
|
1011
|
+
if (spoilerSegment.textView == textView) {
|
|
1012
|
+
if (handleSpoilerTap(textView, recognizer, spoilerSegment.spoilerManager))
|
|
1013
|
+
return;
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
ENRMHandleTapOnTextView(textView, recognizer, ^(NSString *url) { [self emitLinkPress:url]; });
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
// TODO: Remove API_AVAILABLE(ios(16.0)) guard when the minimum iOS deployment target in RN is bumped to 16.
|
|
1023
|
+
#if !TARGET_OS_OSX
|
|
1024
|
+
- (UIMenu *)textView:(UITextView *)textView
|
|
1025
|
+
editMenuForTextInRange:(NSRange)range
|
|
1026
|
+
suggestedActions:(NSArray<UIMenuElement *> *)suggestedActions API_AVAILABLE(ios(16.0))
|
|
1027
|
+
{
|
|
1028
|
+
__weak EnrichedMarkdown *weakSelf = self;
|
|
1029
|
+
ENRMContextMenuPressHandler handler =
|
|
1030
|
+
^(NSString *itemText, NSString *selectedText, NSUInteger selectionStart, NSUInteger selectionEnd) {
|
|
1031
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
1032
|
+
if (strongSelf)
|
|
1033
|
+
[strongSelf emitContextMenuItemPress:itemText
|
|
1034
|
+
selectedText:selectedText
|
|
1035
|
+
selectionStart:selectionStart
|
|
1036
|
+
selectionEnd:selectionEnd];
|
|
1037
|
+
};
|
|
1038
|
+
NSMutableArray<UIAction *> *customActions =
|
|
1039
|
+
ENRMBuildContextMenuActions(_contextMenuItemTexts, _contextMenuItemIcons, textView, range, handler);
|
|
1040
|
+
|
|
1041
|
+
NSString *segmentMarkdown = extractMarkdownFromAttributedString(textView.attributedText, range);
|
|
1042
|
+
return buildEditMenuForSelection(textView.attributedText, range, segmentMarkdown, _config, suggestedActions,
|
|
1043
|
+
customActions, _selectionMenuConfig);
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
- (BOOL)textView:(UITextView *)textView
|
|
1047
|
+
shouldInteractWithURL:(NSURL *)URL
|
|
1048
|
+
inRange:(NSRange)characterRange
|
|
1049
|
+
interaction:(UITextItemInteraction)interaction
|
|
1050
|
+
{
|
|
1051
|
+
if (interaction != UITextItemInteractionPresentActions) {
|
|
1052
|
+
return YES;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
NSString *urlString = linkURLAtRange(textView, characterRange);
|
|
1056
|
+
|
|
1057
|
+
if (!urlString || _enableLinkPreview) {
|
|
1058
|
+
return YES;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
[self emitLinkLongPress:urlString];
|
|
1062
|
+
return NO;
|
|
1063
|
+
}
|
|
1064
|
+
#endif
|
|
1065
|
+
|
|
1066
|
+
- (BOOL)isAccessibilityElement
|
|
1067
|
+
{
|
|
1068
|
+
return NO;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
- (NSArray *)accessibilityElements
|
|
1072
|
+
{
|
|
1073
|
+
NSMutableArray *allElements = [NSMutableArray array];
|
|
1074
|
+
for (RCTUIView *segment in _segmentViews) {
|
|
1075
|
+
if ([segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
1076
|
+
NSArray *elements = [(EnrichedMarkdownInternalText *)segment accessibilityElements];
|
|
1077
|
+
if (elements) {
|
|
1078
|
+
[allElements addObjectsFromArray:elements];
|
|
1079
|
+
}
|
|
1080
|
+
} else if ([segment isKindOfClass:[TableContainerView class]]) {
|
|
1081
|
+
NSArray *elements = [(TableContainerView *)segment accessibilityElements];
|
|
1082
|
+
if (elements) {
|
|
1083
|
+
[allElements addObjectsFromArray:elements];
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
#if ENRICHED_MARKDOWN_MATH
|
|
1087
|
+
else if ([segment isKindOfClass:[ENRMMathContainerView class]]) {
|
|
1088
|
+
[allElements addObject:segment];
|
|
1089
|
+
}
|
|
1090
|
+
#endif
|
|
1091
|
+
}
|
|
1092
|
+
return allElements;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
- (NSInteger)accessibilityElementCount
|
|
1096
|
+
{
|
|
1097
|
+
return [self accessibilityElements].count;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
- (id)accessibilityElementAtIndex:(NSInteger)index
|
|
1101
|
+
{
|
|
1102
|
+
NSArray *elements = [self accessibilityElements];
|
|
1103
|
+
if (index < 0 || index >= (NSInteger)elements.count) {
|
|
1104
|
+
return nil;
|
|
1105
|
+
}
|
|
1106
|
+
return elements[index];
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
- (NSInteger)indexOfAccessibilityElement:(id)element
|
|
1110
|
+
{
|
|
1111
|
+
return [[self accessibilityElements] indexOfObject:element];
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
#if !TARGET_OS_OSX
|
|
1115
|
+
- (NSArray<UIAccessibilityCustomRotor *> *)accessibilityCustomRotors
|
|
1116
|
+
{
|
|
1117
|
+
return [MarkdownAccessibilityElementBuilder buildRotorsFromElements:[self accessibilityElements]];
|
|
1118
|
+
}
|
|
1119
|
+
#endif
|
|
1120
|
+
|
|
1121
|
+
@end
|