react-native-enriched-markdown-scaffold 1.0.2-scaffold.9 → 1.2.0-scaffold.2
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/ReactNativeEnrichedMarkdown.podspec +31 -10
- package/android/build.gradle +49 -12
- package/android/consumer-rules.pro +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +18 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +6 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerDelegate.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +1 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +18 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +6 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +62 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +44 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +67 -2
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +929 -178
- package/android/src/main/baseline-prof.txt +21 -22
- package/android/src/main/cpp/jni-adapter.cpp +17 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +729 -768
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +72 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +222 -8
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +65 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +191 -26
- package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/AccessibleMarkdownTextView.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/MarkdownAccessibilityHelper.kt +54 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/events/CodeBlockPressEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/ImagePressEvent.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/LatexErrorEvent.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputManager.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +101 -9
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditPipeline.kt +48 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/InputConnectionWrapper.kt +7 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MarkdownShortcutMatcher.kt +64 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputRemend.kt +44 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputEventEmitter.kt +9 -8
- package/android/src/main/java/com/swmansion/enriched/markdown/math/LatexErrorReporter.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/MarkdownASTNode.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +5 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlankLineRenderer.kt +38 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockStyleContext.kt +2 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteRenderer.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteTextRenderer.kt +55 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeBlockRenderer.kt +8 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HighlightRenderer.kt +10 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +31 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ParagraphRenderer.kt +17 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/Renderer.kt +40 -21
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/AdmonitionIcons.kt +62 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/BlockSegmentView.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/BlockquoteContainerView.kt +401 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/CodeBlockContainerView.kt +55 -16
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/ContainerNodeView.kt +164 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/MarkdownSegment.kt +21 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/RenderedSegment.kt +137 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentHeightMeasurer.kt +139 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/SegmentReconciler.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/SegmentSignature.kt +3 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentViewCreators.kt +262 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentViewFactory.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/TableContainerView.kt +100 -36
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBackgroundSpan.kt +18 -17
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBlockSpan.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/HighlightSpan.kt +60 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ImageSpan.kt +15 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineBackgroundGeometry.kt +42 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineChipPainter.kt +4 -27
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LineHeightSpan.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerDrawUtils.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/BlockquoteStyle.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkVariantEntry.kt +2 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleConfig.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/VideoStyle.kt +31 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/BorderStyleUtils.kt +86 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/EllipsizeUtils.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/EnrichedMarkdownAncestorUtils.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/FeatureFlags.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/ReadableMapExtensions.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt +227 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/PasteTextUtils.kt +34 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/HTMLGenerator.kt +50 -28
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/MarkdownExtractor.kt +16 -21
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/SpannableExtensions.kt +4 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/BlockSpacing.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/SpanFlags.kt +13 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/CodeBlockPressHost.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/ImagePressHost.kt +19 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkEvents.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLongPressMovementMethod.kt +87 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/TextViewSetup.kt +79 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/conversions.h +2 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +9 -3
- package/android/src/math/java/com/swmansion/enriched/markdown/{views → segments}/MathContainerView.kt +86 -29
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +33 -7
- package/android/src/video/java/com/swmansion/enriched/markdown/segments/VideoContainerView.kt +115 -0
- package/cpp/md4c/md4c.c +343 -236
- package/cpp/md4c/md4c.h +28 -11
- package/cpp/parser/MD4CParser.cpp +266 -4
- package/cpp/parser/MD4CParser.hpp +6 -2
- package/cpp/parser/MarkdownASTNode.hpp +4 -1
- package/cpp/wasm/ASTSerializer.cpp +6 -0
- package/cpp/wasm/md4c_wasm.cpp +5 -1
- package/docs/API_REFERENCE.md +199 -12
- package/docs/BREAKING_CHANGES.md +75 -0
- package/docs/CODE_HIGHLIGHT.md +4 -0
- package/docs/COPY_OPTIONS.md +52 -9
- package/docs/ELEMENTS_STRUCTURE.md +48 -1
- package/docs/INPUT.md +60 -3
- package/docs/LATEX_MATH.md +30 -0
- package/docs/MACOS.md +1 -1
- package/docs/MENTIONS.md +2 -2
- package/docs/STYLES.md +27 -0
- package/docs/TEXT.md +8 -0
- package/docs/WEB.md +44 -10
- package/ios/EnrichedMarkdown.mm +285 -43
- package/ios/EnrichedMarkdownText.mm +185 -23
- package/ios/attachments/ENRMImageAttachment.h +17 -2
- package/ios/attachments/ENRMImageAttachment.m +26 -28
- package/ios/attachments/ENRMMathInlineAttachment+macOS.m +10 -2
- package/ios/attachments/ENRMMathInlineAttachment.h +3 -1
- package/ios/attachments/ENRMMathInlineAttachment.m +17 -1
- package/ios/attachments/ENRMMathInlineAttachmentShared.h +3 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +62 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +44 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +67 -2
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +929 -178
- package/ios/input/ENRMInputFormatter.mm +68 -12
- package/ios/input/ENRMInputFormatterStyle.mm +9 -2
- package/ios/input/ENRMInputParser.mm +18 -0
- package/ios/input/ENRMInputRemend.mm +40 -3
- package/ios/input/ENRMMarkdownShortcutMatcher.h +39 -0
- package/ios/input/ENRMMarkdownShortcutMatcher.mm +66 -0
- package/ios/input/EnrichedMarkdownTextInput.mm +129 -1
- package/ios/internals/ENRMViewFreeMeasurement.h +45 -6
- package/ios/internals/MeasurementCache.h +20 -4
- package/ios/internals/ShadowMeasurementUtils.h +2 -0
- package/ios/math/ENRMLatexErrorCoordinator.h +27 -0
- package/ios/math/ENRMLatexErrorCoordinator.mm +75 -0
- package/ios/math/ENRMLatexErrorReporting.h +13 -0
- package/ios/math/ENRMRaTeXBridge.swift +46 -3
- package/ios/parser/ENRMMarkdownParser.h +3 -0
- package/ios/parser/ENRMMarkdownParser.mm +11 -2
- package/ios/parser/MarkdownASTNode.h +8 -1
- package/ios/parser/MarkdownASTNode.m +20 -0
- package/ios/parser/MarkdownParserBridge.mm +13 -2
- package/ios/renderer/AttributedRenderer.h +13 -1
- package/ios/renderer/AttributedRenderer.m +24 -13
- package/ios/renderer/BaselineShiftTextAttributes.h +4 -0
- package/ios/renderer/BaselineShiftTextAttributes.m +4 -0
- package/ios/renderer/BlankLineRenderer.h +4 -0
- package/ios/renderer/BlankLineRenderer.m +51 -0
- package/ios/renderer/BlockquoteRenderer.m +1 -0
- package/ios/renderer/CodeBlockRenderer.m +8 -0
- package/ios/renderer/CodeRenderer.m +5 -2
- package/ios/renderer/ENRMBlockquoteTextRenderer.h +25 -0
- package/ios/renderer/ENRMBlockquoteTextRenderer.m +48 -0
- package/ios/renderer/ENRMImageRenderer.m +1 -1
- package/ios/renderer/ENRMMathInlineRenderer.m +9 -1
- package/ios/renderer/HeadingRenderer.m +1 -0
- package/ios/renderer/HighlightRenderer.m +6 -0
- package/ios/renderer/LinkRenderer.m +1 -1
- package/ios/renderer/ListItemRenderer.m +51 -2
- package/ios/renderer/ParagraphRenderer.m +10 -3
- package/ios/renderer/RenderContext.h +16 -0
- package/ios/renderer/RenderContext.m +16 -0
- package/ios/renderer/RendererFactory.m +6 -0
- package/ios/renderer/SubscriptRenderer.m +1 -0
- package/ios/renderer/SuperscriptRenderer.m +1 -0
- package/ios/segments/ENRMAdmonitionIcons.h +31 -0
- package/ios/segments/ENRMAdmonitionIcons.m +93 -0
- package/ios/segments/ENRMBlockquoteContainerView.h +90 -0
- package/ios/segments/ENRMBlockquoteContainerView.mm +551 -0
- package/ios/{views → segments}/ENRMCodeBlockContainerView.h +9 -4
- package/ios/{views → segments}/ENRMCodeBlockContainerView.m +147 -36
- package/ios/segments/ENRMContainerNodeView.h +52 -0
- package/ios/segments/ENRMContainerNodeView.mm +201 -0
- package/ios/segments/ENRMDynamicBlockProps.h +32 -0
- package/ios/segments/ENRMDynamicBlockProps.m +15 -0
- package/ios/{views → segments}/ENRMMathContainerView.h +13 -5
- package/ios/{views → segments}/ENRMMathContainerView.m +60 -9
- package/ios/segments/ENRMSVGPath.h +21 -0
- package/ios/segments/ENRMSVGPath.m +409 -0
- package/ios/segments/ENRMSegmentHeightMeasurer.h +33 -0
- package/ios/segments/ENRMSegmentHeightMeasurer.mm +94 -0
- package/ios/segments/ENRMVideoContainerView.h +40 -0
- package/ios/segments/ENRMVideoContainerView.m +421 -0
- package/ios/{utils → segments}/RenderedMarkdownSegment.h +19 -2
- package/ios/{utils → segments}/RenderedMarkdownSegment.m +42 -1
- package/ios/segments/SegmentRenderer.h +26 -0
- package/ios/{utils → segments}/SegmentRenderer.m +46 -9
- package/ios/{views → segments}/TableContainerView.h +5 -4
- package/ios/{views → segments}/TableContainerView.m +96 -12
- package/ios/styles/StyleConfig.h +17 -0
- package/ios/styles/StyleConfig.mm +90 -0
- package/ios/utils/ENRMCodeBlockContent.mm +13 -0
- package/ios/utils/ENRMFeatureFlags.h +6 -0
- package/ios/utils/ENRMTextRenderer.h +8 -0
- package/ios/utils/ENRMTextRenderer.m +26 -10
- package/ios/utils/ENRMUIKit.h +1 -0
- package/ios/utils/FontUtils.h +2 -1
- package/ios/utils/FontUtils.m +22 -6
- package/ios/utils/LinkTapUtils.h +17 -2
- package/ios/utils/LinkTapUtils.m +44 -2
- package/ios/utils/ListMarkerDrawer.m +25 -1
- package/ios/utils/MarkdownASTSerializer.h +7 -0
- package/ios/utils/MarkdownASTSerializer.m +243 -0
- package/ios/utils/MarkdownAccessibilityElementBuilder.m +9 -67
- package/ios/utils/MarkdownExtractor.m +6 -3
- package/ios/utils/ParagraphStyleUtils.h +25 -1
- package/ios/utils/ParagraphStyleUtils.m +51 -7
- package/ios/utils/StylePropsUtils.h +60 -1
- package/ios/utils/TextViewLayoutManager.mm +57 -0
- package/lib/module/EnrichedMarkdownNativeComponent.ts +110 -4
- package/lib/module/EnrichedMarkdownTextInput.js +60 -2
- package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
- package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +12 -0
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +115 -4
- package/lib/module/admonitionDefaults.js +34 -0
- package/lib/module/admonitionDefaults.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +84 -4
- package/lib/module/jest/index.js.map +1 -1
- package/lib/module/native/EnrichedMarkdownText.js +58 -5
- package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/normalizeMarkdownShortcuts.js +31 -0
- package/lib/module/normalizeMarkdownShortcuts.js.map +1 -0
- package/lib/module/normalizeMarkdownStyle.js +15 -1
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.web.js +15 -1
- package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
- package/lib/module/styleUtils.js +15 -3
- package/lib/module/styleUtils.js.map +1 -1
- package/lib/module/utils/textInputState.js +4 -3
- package/lib/module/utils/textInputState.js.map +1 -1
- package/lib/module/utils/usePressability.js +28 -0
- package/lib/module/utils/usePressability.js.map +1 -0
- package/lib/module/web/EnrichedMarkdownText.js +19 -6
- package/lib/module/web/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/web/globalStyles.js +7 -1
- package/lib/module/web/globalStyles.js.map +1 -1
- package/lib/module/web/nativeProps.js +70 -0
- package/lib/module/web/nativeProps.js.map +1 -0
- package/lib/module/web/parseMarkdown.js +5 -3
- package/lib/module/web/parseMarkdown.js.map +1 -1
- package/lib/module/web/renderers/BlockRenderers.js +164 -8
- package/lib/module/web/renderers/BlockRenderers.js.map +1 -1
- package/lib/module/web/renderers/admonitionIcons.js +34 -0
- package/lib/module/web/renderers/admonitionIcons.js.map +1 -0
- package/lib/module/web/styles.js +30 -8
- package/lib/module/web/styles.js.map +1 -1
- package/lib/module/web/wasm/md4c.js +0 -0
- package/lib/module/web/wasm/md4c.js.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +103 -3
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +27 -3
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +11 -0
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +108 -3
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/admonitionDefaults.d.ts +10 -0
- package/lib/typescript/src/admonitionDefaults.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +1 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/jest/index.d.ts +2 -2
- package/lib/typescript/src/jest/index.d.ts.map +1 -1
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +3 -3
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownShortcuts.d.ts +7 -0
- package/lib/typescript/src/normalizeMarkdownShortcuts.d.ts.map +1 -0
- package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
- package/lib/typescript/src/styleUtils.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts +59 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +21 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.d.ts +93 -8
- package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +25 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -1
- package/lib/typescript/src/types/events.d.ts +33 -5
- package/lib/typescript/src/types/events.d.ts.map +1 -1
- package/lib/typescript/src/utils/textInputState.d.ts +5 -3
- package/lib/typescript/src/utils/textInputState.d.ts.map +1 -1
- package/lib/typescript/src/utils/usePressability.d.ts +24 -0
- package/lib/typescript/src/utils/usePressability.d.ts.map +1 -0
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts +1 -1
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/web/globalStyles.d.ts +1 -0
- package/lib/typescript/src/web/globalStyles.d.ts.map +1 -1
- package/lib/typescript/src/web/nativeProps.d.ts +34 -0
- package/lib/typescript/src/web/nativeProps.d.ts.map +1 -0
- package/lib/typescript/src/web/parseMarkdown.d.ts +1 -1
- package/lib/typescript/src/web/parseMarkdown.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/BlockRenderers.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/admonitionIcons.d.ts +5 -0
- package/lib/typescript/src/web/renderers/admonitionIcons.d.ts.map +1 -0
- package/lib/typescript/src/web/styles.d.ts +1 -0
- package/lib/typescript/src/web/styles.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +8 -2
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/postinstall.mjs +7 -0
- package/src/EnrichedMarkdownNativeComponent.ts +110 -4
- package/src/EnrichedMarkdownTextInput.tsx +101 -4
- package/src/EnrichedMarkdownTextInputNativeComponent.ts +12 -0
- package/src/EnrichedMarkdownTextNativeComponent.ts +115 -4
- package/src/admonitionDefaults.ts +58 -0
- package/src/index.tsx +5 -0
- package/src/index.web.tsx +3 -0
- package/src/jest/index.tsx +138 -5
- package/src/native/EnrichedMarkdownText.tsx +55 -3
- package/src/normalizeMarkdownShortcuts.ts +38 -0
- package/src/normalizeMarkdownStyle.ts +17 -0
- package/src/normalizeMarkdownStyle.web.ts +17 -0
- package/src/styleUtils.ts +17 -6
- package/src/types/MarkdownStyle.ts +62 -1
- package/src/types/MarkdownStyleInternal.ts +24 -0
- package/src/types/MarkdownTextProps.ts +95 -7
- package/src/types/MarkdownTextProps.web.ts +26 -0
- package/src/types/events.ts +36 -5
- package/src/utils/textInputState.ts +5 -3
- package/src/utils/usePressability.ts +34 -0
- package/src/web/EnrichedMarkdownText.tsx +36 -3
- package/src/web/globalStyles.ts +10 -0
- package/src/web/nativeProps.ts +78 -0
- package/src/web/parseMarkdown.ts +10 -2
- package/src/web/renderers/BlockRenderers.tsx +175 -6
- package/src/web/renderers/admonitionIcons.ts +37 -0
- package/src/web/styles.ts +28 -3
- package/src/web/types.ts +12 -1
- package/src/web/wasm/md4c.js +0 -0
- package/vendor-ratex.mjs +86 -17
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/DocumentRenderer.kt +0 -16
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/RenderedSegment.kt +0 -88
- package/ios/utils/SegmentRenderer.h +0 -24
- /package/ios/{views → segments}/ENRMTableGridView.h +0 -0
- /package/ios/{views → segments}/ENRMTableGridView.m +0 -0
- /package/ios/{views → segments}/ENRMTableIOSGridView.h +0 -0
- /package/ios/{views → segments}/ENRMTableIOSGridView.m +0 -0
- /package/ios/{utils → segments}/SegmentReconciler.h +0 -0
- /package/ios/{utils → segments}/SegmentReconciler.m +0 -0
- /package/ios/{utils → segments}/SegmentViewRegistry.h +0 -0
- /package/ios/{utils → segments}/SegmentViewRegistry.m +0 -0
package/docs/API_REFERENCE.md
CHANGED
|
@@ -115,13 +115,36 @@ The returned node is placed inside an absolutely positioned box matching `rect`,
|
|
|
115
115
|
Notes and limitations:
|
|
116
116
|
|
|
117
117
|
- When this prop is not set the component renders exactly as before: no wrapper view and no layout events.
|
|
118
|
-
- Setting it wraps the native view in a `View
|
|
118
|
+
- Setting it wraps the native view in a `View`. The wrapper takes `containerStyle` and the native view underneath gets none, so rects and the wrapper share one origin even when `containerStyle` has padding. Switching between set and unset remounts the native view.
|
|
119
119
|
- Rects are measured natively after layout and sent to JS, so decorations appear one frame after the text. Updates are deduplicated — streaming does not re-render decorations unless a link actually moves.
|
|
120
120
|
- Links inside tables (`flavor="github"`) are not reported.
|
|
121
|
+
- With `flavor="github"`, links inside blockquotes and admonitions (nested views) are reported like any other link: `index` follows document order and rects are relative to the component's content box, not to the blockquote.
|
|
122
|
+
- With [`numberOfLines`](#numberoflines) (CommonMark only), line fragments hidden by the clamp or the ellipsis are not reported, so no decoration floats over hidden text, and a link with no visible fragment gets no decoration. On Android a clamped view's links are not tappable (see `numberOfLines`), but their decorations are still drawn.
|
|
121
123
|
- On Android, parts of a decoration that overflow the component's bounds do not receive touches.
|
|
122
124
|
- Web: `rect` is the link's whole inline box and `rects` is `[rect]`; for a wrapping link the decoration anchors to that box rather than the last line.
|
|
123
125
|
- Not supported by `EnrichedMarkdownTextInput`.
|
|
124
126
|
|
|
127
|
+
### `onImagePress`
|
|
128
|
+
|
|
129
|
+
Callback when a rendered image is tapped or clicked. Access the image URL via `event.url` and its Markdown alt text via `event.altText` (`""` when the image has no alt text). Use it to open a lightbox or full-screen viewer.
|
|
130
|
+
|
|
131
|
+
Fires for block and inline images, including images inside headings, lists, and blockquotes. An image that is also a link (`[](dest)`) keeps link behavior and fires [`onLinkPress`](#onlinkpress) instead, so a single tap never fires both. Not fired for images inside GFM tables.
|
|
132
|
+
|
|
133
|
+
Setting this callback makes images interactive on the native side; leaving it unset keeps the existing tap, text-selection, and long-press menu behavior unchanged. On web the image becomes focusable, exposes a button role for screen readers, and can be activated with Enter/Space, while the browser's right-click menu is preserved.
|
|
134
|
+
|
|
135
|
+
| Type | Default Value | Platform |
|
|
136
|
+
| ------------------------------------- | ------------- | ---------------- |
|
|
137
|
+
| `(event: ImagePressEvent) => void` | - | Both, macOS, Web |
|
|
138
|
+
|
|
139
|
+
**Example:**
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
<EnrichedMarkdownText
|
|
143
|
+
markdown=""
|
|
144
|
+
onImagePress={({ url, altText }) => openLightbox({ url, altText })}
|
|
145
|
+
/>
|
|
146
|
+
```
|
|
147
|
+
|
|
125
148
|
### `onTaskListItemPress`
|
|
126
149
|
|
|
127
150
|
Callback when a task list checkbox is tapped. Receives `index` (0-based), `checked` (new state after toggling), and `text` (item text).
|
|
@@ -177,7 +200,7 @@ Only fires when `flavor="github"` — the copy button is part of the GitHub flav
|
|
|
177
200
|
|
|
178
201
|
### `onCopy`
|
|
179
202
|
|
|
180
|
-
Takes over the **Copy** item of the text selection menu and of the table, math
|
|
203
|
+
Takes over the **Copy** item of the text selection menu and of the table, math, code block and blockquote/admonition menus. When set, native does **not** write the clipboard: it calls `onCopy` with the copied content and your handler writes whatever it wants — for example with [`expo-clipboard`](https://docs.expo.dev/versions/latest/sdk/clipboard/). Use it to post-process what users copy (strip formatting, drop link targets…) without a native change.
|
|
181
204
|
|
|
182
205
|
| Type | Default Value | Platform |
|
|
183
206
|
| ----------------------------- | ------------- | -------- |
|
|
@@ -186,7 +209,7 @@ Takes over the **Copy** item of the text selection menu and of the table, math a
|
|
|
186
209
|
```ts
|
|
187
210
|
interface CopyEvent {
|
|
188
211
|
/** Which menu the Copy item belongs to. */
|
|
189
|
-
source: 'selection' | 'math' | 'table' | 'code';
|
|
212
|
+
source: 'selection' | 'math' | 'table' | 'code' | 'blockquote';
|
|
190
213
|
/** What `copy.format: 'markdown'` would write. */
|
|
191
214
|
markdown: string;
|
|
192
215
|
/** Rendered text of the selection, or the block's raw content. */
|
|
@@ -202,11 +225,14 @@ interface CopyEvent {
|
|
|
202
225
|
| `math` | `$$…$$` | LaTeX |
|
|
203
226
|
| `table` | The table as Markdown | Tab-separated cells |
|
|
204
227
|
| `code` | Fenced code block | Raw code |
|
|
228
|
+
| `blockquote`| The blockquote or admonition as Markdown (`flavor="github"`) | The quote's rendered text |
|
|
205
229
|
|
|
206
230
|
- `onCopy` overrides `selectionMenuConfig.copy.format`; `copy.enabled: false` still hides the item, so no event fires.
|
|
207
231
|
- **Copy as Markdown**, the code block header copy button and the VoiceOver copy action are unaffected. `onCopyPress` does not fire for an intercepted Copy.
|
|
208
232
|
- With `flavor="github"` the text is split into segments around blocks, so a selection is `whole` only when the markdown renders as a single text segment.
|
|
209
233
|
- A rebuilt `markdown` wraps each styled run separately (`**a *****b***** c**`) and does not escape literal `*` / `_`.
|
|
234
|
+
- `'blockquote'` is reported for the long-press menu that blockquotes and admonitions get with `flavor="github"`. Code that switches over `source` must handle it.
|
|
235
|
+
- `contextMenuHidden` takes precedence: with it set, no menu shows, so `onCopy` never fires (use [`onSelectionChange`](#onselectionchange) instead).
|
|
210
236
|
- Copying with a hardware keyboard (Cmd+C / Ctrl+C) does not go through the menu and is not intercepted.
|
|
211
237
|
- Ignored on macOS. On web the prop is not this API: it reaches the container `div` as the DOM `onCopy` clipboard event.
|
|
212
238
|
|
|
@@ -223,6 +249,32 @@ import * as Clipboard from 'expo-clipboard';
|
|
|
223
249
|
/>
|
|
224
250
|
```
|
|
225
251
|
|
|
252
|
+
### `onLatexError`
|
|
253
|
+
|
|
254
|
+
Callback when a math expression cannot be parsed or rendered by the LaTeX engine. Receives `source` (the raw LaTeX of the failing expression, without `$`/`$$` delimiters), `message` (the engine's error message, or `undefined` when the engine provides none), and `displayMode` (`false` for inline `$...$`, `true` for block `$$...$$`).
|
|
255
|
+
|
|
256
|
+
The whole expression is the unit of failure - the engine either renders an expression in full or rejects it, so there is no single offending command and therefore no `command` field. Use `source` to report the failing formula to your own error tracker without maintaining an allowlist that goes stale on engine upgrades.
|
|
257
|
+
|
|
258
|
+
Fires **at most once per distinct failing expression** per component instance - the callback is de-duplicated (keyed by `displayMode` + `source`) and the cache is kept across `markdown` changes, so streaming content does not re-report the same failure on every update. Requires `md4cFlags.latexMath` (on by default).
|
|
259
|
+
|
|
260
|
+
> [!CAUTION]
|
|
261
|
+
> De-duplication is per component **instance**. If the component unmounts and remounts (new instance - navigation, a changed React `key`, or list recycling), it reports the same failures again. De-duplicate on your side (e.g. by `source`) if you aggregate these app-wide. See [LaTeX Math - De-duplication and re-mounts](LATEX_MATH.md#de-duplication-and-re-mounts).
|
|
262
|
+
|
|
263
|
+
| Type | Default Value | Platform |
|
|
264
|
+
| ------------------------------------- | ------------- | ------------ |
|
|
265
|
+
| `(event: LatexErrorEvent) => void` | - | iOS, Android |
|
|
266
|
+
|
|
267
|
+
**Example:**
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
<EnrichedMarkdownText
|
|
271
|
+
markdown={"Inline $\\foo$ and block:\n\n$$\\bar$$"}
|
|
272
|
+
onLatexError={({ source, message, displayMode }) => {
|
|
273
|
+
reportToErrorTracker('latex-render-failed', { source, message, displayMode });
|
|
274
|
+
}}
|
|
275
|
+
/>
|
|
276
|
+
```
|
|
277
|
+
|
|
226
278
|
### `onSelectionChange`
|
|
227
279
|
|
|
228
280
|
Reports the text selection so the app can draw its own selection menu. Pair it with [`contextMenuHidden`](#contextmenuhidden) to replace the native menu entirely.
|
|
@@ -238,7 +290,7 @@ interface SelectionChangeEvent {
|
|
|
238
290
|
/** `false` once the selection is gone; every other field is then empty / zero. */
|
|
239
291
|
active: boolean;
|
|
240
292
|
/** `'selection'` for text, or the kind of a long-pressed block. */
|
|
241
|
-
source: 'selection' | 'math' | 'table' | 'code';
|
|
293
|
+
source: 'selection' | 'math' | 'table' | 'code' | 'blockquote';
|
|
242
294
|
/** Same as `CopyEvent.text` / `CopyEvent.markdown` / `CopyEvent.whole`. */
|
|
243
295
|
text: string;
|
|
244
296
|
markdown: string;
|
|
@@ -255,8 +307,9 @@ interface SelectionChangeEvent {
|
|
|
255
307
|
|
|
256
308
|
- Fires at most once per frame while the selection changes (payloads are deduplicated), and with `active: false` right away once it is gone — including when new `markdown` replaces the text.
|
|
257
309
|
- Rects are in dp, relative to the component's native view: add the origin from `ref.current.measureInWindow` to get window coordinates. Re-measure after scrolling instead of waiting for a new event.
|
|
258
|
-
- With `contextMenuHidden`, a long press on a table, math
|
|
310
|
+
- With `contextMenuHidden`, a long press on a table, math, code block, blockquote or admonition (`flavor="github"`) fires the event with `source` set to the block kind (`'blockquote'` for blockquotes and admonitions), `whole: true` and every rect set to the block's frame. These blocks have no text selection, so without this they would offer no way to copy. Without `contextMenuHidden` the block menu shows as usual and no event fires.
|
|
259
311
|
- On iOS the selection isn't reported while a handle is dragged: the event fires with `adjusting: true` (and the selection as it was) when the drag begins, and with `adjusting: false` and the new selection when the finger lifts. Hide your menu while `adjusting` is `true`. Android has no such flag (`adjusting` is always `false`) but reports every step of the drag, so debounce before showing the menu there too.
|
|
312
|
+
- Rects of selections and blocks inside a blockquote or admonition (which render as nested views with `flavor="github"`) are still relative to the component's root native view, like every other rect, so the same `measureInWindow` origin applies.
|
|
260
313
|
- Within one component only one part holds a selection at a time: selecting in another text segment clears the previous one. To keep a single selection across several components, call `clearSelection()` on the previous one.
|
|
261
314
|
- Ignored on macOS and web.
|
|
262
315
|
|
|
@@ -281,6 +334,55 @@ const ref = useRef<EnrichedMarkdownTextInstance>(null);
|
|
|
281
334
|
ref.current?.clearSelection();
|
|
282
335
|
```
|
|
283
336
|
|
|
337
|
+
### `onCodeBlockPress`
|
|
338
|
+
|
|
339
|
+
Callback fired when a fenced code block is tapped anywhere in its body. Receives `code` (the block's source) and `language` (the fence language, or `""` if none). Useful for building custom actions such as copy-to-clipboard or opening the code in a viewer.
|
|
340
|
+
|
|
341
|
+
Setting this prop arms the code block for taps. When it is unset the block stays inert - text selection, the header copy button, and the long-press context menu behave exactly as before. A tap never fires while text is being selected; selection still happens via long-press.
|
|
342
|
+
|
|
343
|
+
Works in both flavors: `flavor="github"` fires on the container-based code block renderer, and `flavor="commonmark"` fires on the inline code-block region drawn inside the single text view. On web the code block is rendered as a clickable, keyboard-activatable element (the `flavor` prop is ignored on web).
|
|
344
|
+
|
|
345
|
+
| Type | Default Value | Platform |
|
|
346
|
+
| -------------------------------------- | ------------- | ----------------- |
|
|
347
|
+
| `(event: CodeBlockPressEvent) => void` | - | iOS, Android, Web |
|
|
348
|
+
|
|
349
|
+
**Example:**
|
|
350
|
+
|
|
351
|
+
```tsx
|
|
352
|
+
<EnrichedMarkdownText
|
|
353
|
+
flavor="github"
|
|
354
|
+
markdown={"```ts\nconst x = 1;\n```"}
|
|
355
|
+
onCodeBlockPress={({ code, language }) => {
|
|
356
|
+
Clipboard.setString(code);
|
|
357
|
+
console.log(`Copied ${language} code`);
|
|
358
|
+
}}
|
|
359
|
+
/>
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### `enableBlockContextMenu`
|
|
363
|
+
|
|
364
|
+
Controls the long-press copy popup on code blocks, tables, block math, and blockquotes/admonitions.
|
|
365
|
+
Setting it to `false` leaves the code-block header copy button, accessibility
|
|
366
|
+
copy action, and system text-selection menu unchanged.
|
|
367
|
+
|
|
368
|
+
[`contextMenuHidden`](#contextmenuhidden) wins over this prop: with `contextMenuHidden` set, the block
|
|
369
|
+
popups stay hidden even when `enableBlockContextMenu` is `true`, and a long press on a block is reported
|
|
370
|
+
through [`onSelectionChange`](#onselectionchange) instead. With only `enableBlockContextMenu={false}`, a
|
|
371
|
+
long press on a block shows nothing and reports nothing. See
|
|
372
|
+
[Copy Options](COPY_OPTIONS.md#contextmenuhidden-vs-enableblockcontextmenu).
|
|
373
|
+
|
|
374
|
+
| Type | Default Value | Platform |
|
|
375
|
+
| --------- | ------------- | ------------------- |
|
|
376
|
+
| `boolean` | `true` | iOS, Android, macOS |
|
|
377
|
+
|
|
378
|
+
```tsx
|
|
379
|
+
<EnrichedMarkdownText
|
|
380
|
+
flavor="github"
|
|
381
|
+
markdown={content}
|
|
382
|
+
enableBlockContextMenu={false}
|
|
383
|
+
/>
|
|
384
|
+
```
|
|
385
|
+
|
|
284
386
|
### `enableLinkPreview`
|
|
285
387
|
|
|
286
388
|
Controls the native link preview on long press (iOS only). Automatically set to `false` when `onLinkLongPress` is provided.
|
|
@@ -340,8 +442,11 @@ Notes:
|
|
|
340
442
|
- It hides the **whole** menu. The custom items from `contextMenuItems` and the
|
|
341
443
|
built-in items from `selectionMenuConfig` share that same menu, so they are
|
|
342
444
|
hidden too. To drop individual items instead, use `selectionMenuConfig`.
|
|
343
|
-
- It also covers the separate copy menus on table, code
|
|
344
|
-
appear with `flavor="github"`), not just
|
|
445
|
+
- It also covers the separate copy menus on table, code, math and
|
|
446
|
+
blockquote/admonition blocks (which appear with `flavor="github"`), not just
|
|
447
|
+
the text selection menu. It wins over
|
|
448
|
+
[`enableBlockContextMenu`](#enableblockcontextmenu): block menus stay hidden
|
|
449
|
+
even when that prop is `true`. The copy
|
|
345
450
|
button in a code block's header is a visible control, not a menu, and stays.
|
|
346
451
|
- It does **not** suppress the system "Save to Camera Roll / Copy" sheet that
|
|
347
452
|
UIKit shows when long-pressing an image — that sheet is owned by UIKit.
|
|
@@ -374,7 +479,7 @@ Configuration for md4c parser extension flags.
|
|
|
374
479
|
|
|
375
480
|
| Type | Default Value | Platform |
|
|
376
481
|
| ------------- | ------------------------ | -------- |
|
|
377
|
-
| `Md4cFlags` | `{ underline: false, superscript: false, subscript: false, highlight: false, latexMath: true, hardSoftBreaks: false }` | Both |
|
|
482
|
+
| `Md4cFlags` | `{ underline: false, superscript: false, subscript: false, highlight: false, latexMath: true, hardSoftBreaks: false, preserveBlankLines: false, admonitions: true }` | Both |
|
|
378
483
|
|
|
379
484
|
**Properties:**
|
|
380
485
|
|
|
@@ -384,6 +489,10 @@ Configuration for md4c parser extension flags.
|
|
|
384
489
|
- **`highlight`**: When `true`, parses `==text==` as highlighted spans. When disabled, double equals signs are treated as plain text. Visual appearance can be tuned with the `highlight` style prop — see [Highlight-specific](./STYLES.md#highlight-specific).
|
|
385
490
|
- **`latexMath`**: When `true`, parses `$...$` and `$$...$$` as LaTeX math spans.
|
|
386
491
|
- **`hardSoftBreaks`**: When `true`, treats single newlines (soft breaks) as hard breaks, rendering them as visible line breaks instead of collapsing them to spaces. Useful when displaying content authored in `EnrichedMarkdownTextInput`, where pressing Enter produces a single newline. See [Line Breaks](./ELEMENTS_STRUCTURE.md#line-breaks) for details.
|
|
492
|
+
- **`preserveBlankLines`**: When `true`, preserves runs of consecutive blank lines from the source instead of collapsing them into a single paragraph break (per CommonMark). Each blank line renders as one empty line, so the output keeps the exact line count that was typed. See [Blank Lines](./ELEMENTS_STRUCTURE.md#blank-lines) for details.
|
|
493
|
+
- **`admonitions`**: When `true` (the default), GitHub alerts (`> [!NOTE]`, `> [!TIP]`, `> [!IMPORTANT]`, `> [!WARNING]`, `> [!CAUTION]`) render as callouts with an icon and title, colored by `markdownStyle.blockquote.admonitions` (built-in palette otherwise). Only takes effect with `flavor="github"`; always off with `'commonmark'`, where the syntax renders as a plain blockquote.
|
|
494
|
+
|
|
495
|
+
Flags you leave out keep their defaults, so `md4cFlags={{ hardSoftBreaks: true }}` still has `admonitions` on. If your content can contain `> [!NOTE]`-style text that should stay a plain quote (for example LLM output), pass `admonitions: false` explicitly, e.g. `md4cFlags={{ admonitions: false, ...md4cFlags }}` in your wrapper component.
|
|
387
496
|
|
|
388
497
|
**Example:**
|
|
389
498
|
|
|
@@ -430,6 +539,37 @@ Whether to preserve the bottom margin of the last block element.
|
|
|
430
539
|
| --------- | ------------- | -------- |
|
|
431
540
|
| `boolean` | `false` | Both |
|
|
432
541
|
|
|
542
|
+
### `numberOfLines`
|
|
543
|
+
|
|
544
|
+
Clamps the rendered markdown to a maximum number of lines, truncating with an ellipsis (see [`ellipsizeMode`](#ellipsizemode)) when it overflows. `0` (the default) means unlimited. Mirrors the prop of the same name on React Native's core `Text`, and is handy for previews such as chat-list rows or reply quotes. The clamp is applied to both the measurement pass and the rendered view, so the measured and rendered heights stay in sync.
|
|
545
|
+
|
|
546
|
+
Only applies to CommonMark (the default flavor). When [`flavor`](#flavor) is `'github'` the content is laid out as independent block segments that cannot honor a document-wide line cap, so the prop is ignored - see [issue #786](https://github.com/software-mansion/enriched-markdown/issues/786).
|
|
547
|
+
|
|
548
|
+
> **Android note:** while a view is clamped (`numberOfLines > 0`) it is not selectable and its links are not tappable, regardless of [`selectable`](#selectable). This is a platform constraint, not a choice: Android draws the truncation ellipsis only through `StaticLayout`, but enabling text selection or a link movement method promotes the text to a `Spannable`, which forces `TextView` onto `DynamicLayout` - and `DynamicLayout` has no `maxLines` support, so the clamp and its ellipsis are silently dropped (confirmed against AOSP `TextView`/`DynamicLayout` on API 35/36; React Native's own `Text` hits the same limitation). Selection and links are restored automatically once the clamp is removed. iOS keeps selection and links while clamped.
|
|
549
|
+
|
|
550
|
+
> **`renderLinkDecoration` note:** links on lines hidden by the clamp are not reported to [`renderLinkDecoration`](#renderlinkdecoration), so decorations never float over truncated text.
|
|
551
|
+
|
|
552
|
+
| Type | Default Value | Platform |
|
|
553
|
+
| -------- | ------------- | -------- |
|
|
554
|
+
| `number` | `0` | Both |
|
|
555
|
+
|
|
556
|
+
### `ellipsizeMode`
|
|
557
|
+
|
|
558
|
+
Controls where the ellipsis is placed when the text is truncated by [`numberOfLines`](#numberoflines). Only takes effect when `numberOfLines` is set. Mirrors the prop of the same name on React Native's core `Text`.
|
|
559
|
+
|
|
560
|
+
| Type | Default Value | Platform |
|
|
561
|
+
| ------------------------------------------- | ------------- | -------- |
|
|
562
|
+
| `'head' \| 'middle' \| 'tail' \| 'clip'` | `'tail'` | Both |
|
|
563
|
+
|
|
564
|
+
- **`'head'`**: ellipsis at the start (`...d of the text`).
|
|
565
|
+
- **`'middle'`**: ellipsis in the middle (`start...end`).
|
|
566
|
+
- **`'tail'`** (default): ellipsis at the end (`start of the...`).
|
|
567
|
+
- **`'clip'`**: truncate at the line boundary with no ellipsis glyph.
|
|
568
|
+
|
|
569
|
+
> **Multi-line note:** `'head'` and `'middle'` are single-line truncation modes. They only place the ellipsis as described when [`numberOfLines`](#numberoflines) is `1`. With `numberOfLines > 1`, Android only truncates through `StaticLayout`'s `TruncateAt.END`, so `'head'` and `'middle'` fall back to tail-style behavior; iOS multi-line truncation with these modes is likewise unreliable. This mirrors React Native's core `Text`, where only `'tail'` is documented to work correctly past one line. Use `'tail'` (or `'clip'`) for multi-line clamps.
|
|
570
|
+
|
|
571
|
+
Ignored when [`flavor`](#flavor) is `'github'` (see [`numberOfLines`](#numberoflines)).
|
|
572
|
+
|
|
433
573
|
### `textBreakStrategy`
|
|
434
574
|
|
|
435
575
|
Controls how Android breaks lines within paragraphs. Mirrors the prop of the same name on React Native's core `Text`. The same value is used for both the measurement pass (`StaticLayout.Builder`) and the rendered `TextView`, so measured and rendered line counts stay in sync. Requires API 23+; ignored on older Android versions.
|
|
@@ -487,7 +627,7 @@ Code blocks are always rendered left-to-right regardless of this prop. Per-parag
|
|
|
487
627
|
|
|
488
628
|
### `flavor`
|
|
489
629
|
|
|
490
|
-
Markdown flavor. Set to `'github'` to enable GitHub Flavored Markdown features: tables
|
|
630
|
+
Markdown flavor. Set to `'github'` to enable GitHub Flavored Markdown features: tables, block-style code blocks, and block-style blockquotes.
|
|
491
631
|
|
|
492
632
|
| Type | Default Value | Platform |
|
|
493
633
|
| --------------------------------- | --------------- | -------- |
|
|
@@ -495,9 +635,11 @@ Markdown flavor. Set to `'github'` to enable GitHub Flavored Markdown features:
|
|
|
495
635
|
|
|
496
636
|
> **Note:**
|
|
497
637
|
> - **`'commonmark'`**: All Markdown content is rendered as a single TextView. Selecting text will select all content in the view.
|
|
498
|
-
> - **`'github'`**: The Markdown AST is split into segments. Consecutive text blocks (paragraphs, headings, lists, etc.) are grouped into separate TextView segments, while tables, fenced code blocks,
|
|
638
|
+
> - **`'github'`**: The Markdown AST is split into segments. Consecutive text blocks (paragraphs, headings, lists, etc.) are grouped into separate TextView segments, while tables, fenced code blocks, math blocks, and blockquotes are rendered as separate block views. This allows for granular text selection within each segment and enables interactive block features (horizontal table scrolling, context menus, the code block header). Text selection cannot span across segments.
|
|
499
639
|
>
|
|
500
640
|
> With `'github'`, a fenced code block renders as a dedicated component: a header bar with the language display name (` ```python ` shows "Python") and a copy-code button, a divider, and the code below. Long lines do not wrap — the code pane scrolls horizontally while the header stays fixed. Long-pressing the block opens the Copy / Copy as Markdown menu. With `'commonmark'`, code blocks stay inside the single TextView, styled via spans, and long lines wrap.
|
|
641
|
+
>
|
|
642
|
+
> With `'github'`, a blockquote also renders as a dedicated component — a recursive container that draws its own box (padding, `backgroundColor`, and accent border with `borderRadius`) and splits its own content into segments. A code block, table, or math block quoted inside therefore becomes a real nested block component, and each nesting level is its own box. Long-pressing a blockquote or admonition opens the Copy / Copy as Markdown menu; [`contextMenuHidden`](#contextmenuhidden), [`onCopy`](#oncopy) and [`onSelectionChange`](#onselectionchange) apply to it with `source: 'blockquote'`. GitHub alerts (`> [!NOTE]` …) render as admonitions by default (see [`md4cFlags.admonitions`](#md4cflags)). With `'commonmark'`, blockquotes stay inside the single TextView, styled via spans.
|
|
501
643
|
|
|
502
644
|
### `streamingAnimation`
|
|
503
645
|
|
|
@@ -813,13 +955,34 @@ Whether the input is scrollable when content exceeds the visible area.
|
|
|
813
955
|
|
|
814
956
|
### `blockSyntax`
|
|
815
957
|
|
|
816
|
-
Whether block-level Markdown syntax is interpreted.
|
|
958
|
+
Whether block-level Markdown syntax is interpreted. With `false`, the text round-trips byte for byte
|
|
959
|
+
and [`markdownShortcuts`](#markdownshortcuts) is forced off. See
|
|
817
960
|
[Preserving block syntax](./INPUT.md#preserving-block-syntax).
|
|
818
961
|
|
|
819
962
|
| Type | Default Value | Platform |
|
|
820
963
|
| --------- | ------------- | -------- |
|
|
821
964
|
| `boolean` | `true` | Both |
|
|
822
965
|
|
|
966
|
+
### `markdownShortcuts`
|
|
967
|
+
|
|
968
|
+
Converts markdown block prefixes typed at the start of a paragraph into blocks and removes the prefix: `#`–`######` + space → heading, `-`/`*`/`+` + space → bullet item, `1.`/`1)` + space → numbered item. Only fires on a plain paragraph, and only for text that was typed.
|
|
969
|
+
|
|
970
|
+
`true` enables all three families; a config object enables a subset, where an omitted key is off:
|
|
971
|
+
|
|
972
|
+
```ts
|
|
973
|
+
type MarkdownShortcutsConfig = {
|
|
974
|
+
heading?: boolean;
|
|
975
|
+
unorderedList?: boolean;
|
|
976
|
+
orderedList?: boolean;
|
|
977
|
+
};
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
Forced off when [`blockSyntax`](#blocksyntax) is `false`, whatever this prop says. See [INPUT — Markdown Shortcuts](INPUT.md#markdown-shortcuts).
|
|
981
|
+
|
|
982
|
+
| Type | Default Value | Platform |
|
|
983
|
+
| ------------------------------------- | ------------- | -------- |
|
|
984
|
+
| `boolean \| MarkdownShortcutsConfig` | `false` | Both |
|
|
985
|
+
|
|
823
986
|
### `autoCapitalize`
|
|
824
987
|
|
|
825
988
|
Auto-capitalization behavior.
|
|
@@ -879,7 +1042,7 @@ Style configuration for formatted text in the input.
|
|
|
879
1042
|
- `link.color` — text color for links (defaults to `#2563EB`).
|
|
880
1043
|
- `link.underline` — whether links are underlined (defaults to `true`).
|
|
881
1044
|
- `link.backgroundColor` — background color for links (defaults to `transparent`).
|
|
882
|
-
- `linkVariants` — per-URL-pattern style overrides. Each key is a regex tested against the link URL. See [Mentions — Link Variants](MENTIONS.md#link-variants-
|
|
1045
|
+
- `linkVariants` — per-URL-pattern style overrides. Each key is a regex tested against the link URL. See [Mentions — Link Variants](MENTIONS.md#link-variants-styling).
|
|
883
1046
|
- `spoiler.color` — text color for spoiler text.
|
|
884
1047
|
- `spoiler.backgroundColor` — background color for spoiler text.
|
|
885
1048
|
- `h1`–`h6` — per-level heading styling, each accepting `fontSize`, `fontWeight`, and `color`. Defaults match the read-only renderer (sizes `30/24/20/18/16/14`, bold).
|
|
@@ -1033,6 +1196,30 @@ Fires when the input loses focus.
|
|
|
1033
1196
|
|
|
1034
1197
|
The input participates in React Native's text-input focus tracking (`TextInput.State`), so blur also happens through the platform's standard keyboard-dismiss paths: taps outside the input inside a `ScrollView` (per its `keyboardShouldPersistTaps` setting) and `Keyboard.dismiss()`. See [Keyboard Dismissal](INPUT.md#keyboard-dismissal).
|
|
1035
1198
|
|
|
1199
|
+
### `onPress`, `onPressIn`, `onPressOut`
|
|
1200
|
+
|
|
1201
|
+
Fire for taps on the input, like React Native `TextInput`. The input claims the JS touch responder, so a tap that focuses it does not also fire the `onPress` of an ancestor `Pressable`. After `onPress` runs, the input focuses itself (unless `editable` is `false`) without changing the current selection. As on `TextInput`, responder props passed through `ViewProps` (`onStartShouldSetResponder`, `onResponderGrant`, and the rest) are overridden by the input's press handling.
|
|
1202
|
+
|
|
1203
|
+
| Type | Default Value | Platform |
|
|
1204
|
+
| ------------------------------------------- | ------------- | -------- |
|
|
1205
|
+
| `(event: GestureResponderEvent) => unknown` | - | Both |
|
|
1206
|
+
|
|
1207
|
+
### `hitSlop`
|
|
1208
|
+
|
|
1209
|
+
Extends the touchable area for the press handlers above. Same as `hitSlop` on React Native `TextInput`.
|
|
1210
|
+
|
|
1211
|
+
| Type | Default Value | Platform |
|
|
1212
|
+
| ---------------------- | ------------- | -------- |
|
|
1213
|
+
| `ViewProps['hitSlop']` | - | Both |
|
|
1214
|
+
|
|
1215
|
+
### `rejectResponderTermination`
|
|
1216
|
+
|
|
1217
|
+
When `true`, a parent scroll view or pressable can't take over the touch responder while the input is being pressed. Same as React Native `TextInput`.
|
|
1218
|
+
|
|
1219
|
+
| Type | Default Value | Platform |
|
|
1220
|
+
| --------- | ------------- | -------- |
|
|
1221
|
+
| `boolean` | `true` | iOS |
|
|
1222
|
+
|
|
1036
1223
|
### `onStartMention`
|
|
1037
1224
|
|
|
1038
1225
|
Fires when a new mention flow starts. See [Mentions](MENTIONS.md#events).
|
package/docs/BREAKING_CHANGES.md
CHANGED
|
@@ -5,6 +5,12 @@ This file tracks breaking changes and how to migrate for each. Entries are newes
|
|
|
5
5
|
|
|
6
6
|
## Unreleased
|
|
7
7
|
|
|
8
|
+
## Scaffold fork
|
|
9
|
+
|
|
10
|
+
Entries in this section apply only to the scaffold fork of this library (versions `x.y.z-scaffold.N`).
|
|
11
|
+
They are kept apart from the upstream version sections below, which describe upstream releases as
|
|
12
|
+
published. The fork currently tracks upstream v1.1.1 (`1.1.1-scaffold.*`).
|
|
13
|
+
|
|
8
14
|
### `EnrichedMarkdownTextInput` math style keys renamed to match the renderer
|
|
9
15
|
|
|
10
16
|
The editor's `markdownStyle` used `math` for the **inline** chip and `mathBlock` for the **block**
|
|
@@ -38,6 +44,75 @@ The accompanying types are exported for the first time under names that say whic
|
|
|
38
44
|
to: `InputInlineMathStyle` and `InputMathStyle` (the renderer's own math style types stay internal to
|
|
39
45
|
`MarkdownStyle`).
|
|
40
46
|
|
|
47
|
+
### Upgrading from `1.0.2-scaffold.*` to `1.1.1-scaffold.*`
|
|
48
|
+
|
|
49
|
+
Upstream v1.1.0 and v1.1.1 add no breaking API changes, but several defaults and behaviours change for
|
|
50
|
+
an app that upgrades the fork. Check each item:
|
|
51
|
+
|
|
52
|
+
- **`lineHeight` stays a clamp for text-only lines (fork deviation).** Upstream v1.1.1 made `lineHeight`
|
|
53
|
+
a floor on both platforms (#740, #832). The fork keeps clamping text-only lines to exactly
|
|
54
|
+
`lineHeight`; only lines or blocks with inline math (and block images on iOS) grow to fit. Nothing
|
|
55
|
+
changes for apps already on the fork. See [STYLES.md](STYLES.md#block-styles-paragraph-h1-h6-blockquote-list-codeblock) for the exact rules.
|
|
56
|
+
- **Admonitions are on by default with `flavor="github"`.** `> [!NOTE]`, `> [!TIP]`, `> [!IMPORTANT]`,
|
|
57
|
+
`> [!WARNING]` and `> [!CAUTION]` now render as coloured boxes with an icon, using the built-in
|
|
58
|
+
palette rather than your theme. To keep them as plain blockquotes, pass
|
|
59
|
+
`md4cFlags={{ admonitions: false, ...yourFlags }}`, or theme them through `blockquote.admonitions`.
|
|
60
|
+
Passing a partial `md4cFlags` object (for example `{ hardSoftBreaks: true }`) does **not** turn
|
|
61
|
+
admonitions off; unspecified keys keep their defaults.
|
|
62
|
+
- **Blockquotes and admonitions are nested native views** in the GitHub flavor, with their own long-press
|
|
63
|
+
copy menu (#763). That menu follows the same rules as the other block menus: `contextMenuHidden`
|
|
64
|
+
suppresses it and reports the long-press through `onSelectionChange` (`source: 'blockquote'`), and
|
|
65
|
+
`onCopy` intercepts its Copy (`source: 'blockquote'`). **`CopyEvent.source` and
|
|
66
|
+
`SelectionChangeEvent.source` gained the `'blockquote'` member**, so an exhaustive `switch` over
|
|
67
|
+
`source` needs a new case.
|
|
68
|
+
- **Video playback is on by default** (`enableVideo`). A block-level `<video src="…">` tag renders a
|
|
69
|
+
native player with `flavor="github"`. On Android this compiles in Media3 ExoPlayer 1.6.0, and Gradle
|
|
70
|
+
resolves a single Media3 version for the whole app, so it can clash with another library that brings
|
|
71
|
+
a different Media3 (for example `expo-video`, which uses 1.9.x). Apps that do not need video, or that
|
|
72
|
+
ship `expo-video`, should set `"enableVideo": false` and rebuild.
|
|
73
|
+
- **iOS math is gated on the downloaded RaTeX assets** (`ios/vendor/.stamp`, #745). If `postinstall`
|
|
74
|
+
did not finish, math is silently disabled unless the app sets `"enableMath": true` explicitly, in
|
|
75
|
+
which case `pod install` fails with an actionable error. Since math chips are a core fork feature,
|
|
76
|
+
set `"enableMath": true` explicitly.
|
|
77
|
+
- **`EnrichedMarkdownTextInput` strips backslash escapes on iOS too** (#798). `\*` or `\$` typed or set
|
|
78
|
+
through `defaultValue` / `setValue` shows as a literal `*` / `$` without the backslash, on both
|
|
79
|
+
platforms (Android already did this). The serializer does not escape again, so markdown like
|
|
80
|
+
`\$5 and \$6` does **not** round-trip byte-for-byte: the markdown the input emits is `$5 and $6`,
|
|
81
|
+
which parses as inline math the next time it is loaded. This is a known issue; see
|
|
82
|
+
[Backslash escapes](INPUT.md#backslash-escapes).
|
|
83
|
+
- **`markdownShortcuts` in `EnrichedMarkdownTextInput` is off by default** and is forced off when
|
|
84
|
+
`blockSyntax={false}`. Nothing changes unless you opt in.
|
|
85
|
+
|
|
86
|
+
Recommended `package.json` block for an app that uses math chips and does not need video:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"enriched-markdown": {
|
|
91
|
+
"enableMath": true,
|
|
92
|
+
"enableVideo": false
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
and, if admonitions should stay plain blockquotes, a default in your markdown wrapper:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
<EnrichedMarkdownText
|
|
101
|
+
flavor="github"
|
|
102
|
+
{...props}
|
|
103
|
+
md4cFlags={{ admonitions: false, ...props.md4cFlags }}
|
|
104
|
+
/>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## v1.1.1
|
|
108
|
+
|
|
109
|
+
No breaking changes. v1.1.1 is a patch release over v1.1.0 - every public prop, method, event and style
|
|
110
|
+
key from v1.1.0 keeps its name and behaviour, and no deprecation was introduced or removed.
|
|
111
|
+
|
|
112
|
+
## v1.1.0
|
|
113
|
+
|
|
114
|
+
No breaking changes. v1.1.0 is additive over v1.0.2 - every public prop, method, event and style key
|
|
115
|
+
from v1.0.2 keeps its name and behaviour, and no deprecation was introduced or removed.
|
|
41
116
|
|
|
42
117
|
## v1.0.2
|
|
43
118
|
|
package/docs/CODE_HIGHLIGHT.md
CHANGED
|
@@ -49,6 +49,10 @@ no header, so it has no copy button. To observe when a user copies code, pass
|
|
|
49
49
|
The copy label shown to assistive technologies is configurable via
|
|
50
50
|
[`selectionMenuConfig`](./COPY_OPTIONS.md).
|
|
51
51
|
|
|
52
|
+
To react to a tap anywhere on a code block (for example to build your own copy-to-clipboard
|
|
53
|
+
action), pass [`onCodeBlockPress`](./API_REFERENCE.md#oncodeblockpress) instead — it fires with the
|
|
54
|
+
block's `code` and `language`, in both the `commonmark` and `github` flavors.
|
|
55
|
+
|
|
52
56
|
## Supported languages
|
|
53
57
|
|
|
54
58
|
Fence info strings map to a grammar (for example `js` and `jsx` both select JavaScript). The **curated default
|
package/docs/COPY_OPTIONS.md
CHANGED
|
@@ -37,6 +37,7 @@ Use `selectionMenuConfig` to hide built-in selection menu actions while keeping
|
|
|
37
37
|
```tsx
|
|
38
38
|
<EnrichedMarkdownText
|
|
39
39
|
markdown={content}
|
|
40
|
+
enableBlockContextMenu={false}
|
|
40
41
|
selectionMenuConfig={{
|
|
41
42
|
copyAsMarkdown: { enabled: false },
|
|
42
43
|
copyImageUrl: { enabled: false },
|
|
@@ -44,6 +45,11 @@ Use `selectionMenuConfig` to hide built-in selection menu actions while keeping
|
|
|
44
45
|
/>
|
|
45
46
|
```
|
|
46
47
|
|
|
48
|
+
On iOS, Android, and macOS, `enableBlockContextMenu={false}` disables the
|
|
49
|
+
long-press popup on code blocks, tables, block math, and blockquotes/admonitions.
|
|
50
|
+
It leaves the code-block header copy button, accessibility copy action, and system
|
|
51
|
+
text-selection menu unchanged.
|
|
52
|
+
|
|
47
53
|
### Copy as Markdown only, no system items
|
|
48
54
|
|
|
49
55
|
`copy` can also be hidden (`{ enabled: false }`) or switched to Markdown with
|
|
@@ -63,11 +69,12 @@ Use `selectionMenuConfig` to hide built-in selection menu actions while keeping
|
|
|
63
69
|
```
|
|
64
70
|
|
|
65
71
|
The same `copy` and `copyAsMarkdown` settings drive the long-press menus on
|
|
66
|
-
table, math and
|
|
67
|
-
the block's Markdown (`$$…$$`, a fenced code block, a
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
table, math, code and blockquote/admonition blocks: with `format: 'markdown'`
|
|
73
|
+
their Copy item writes the block's Markdown (`$$…$$`, a fenced code block, a
|
|
74
|
+
Markdown table, the quote's Markdown). On code blocks, the header copy button
|
|
75
|
+
and the VoiceOver copy action always copy the raw code and fire `onCopyPress`;
|
|
76
|
+
`codeBlockCopyButton: { enabled: false }` hides the button, and
|
|
77
|
+
`copy: { enabled: false }` also removes the VoiceOver action.
|
|
71
78
|
`copy.enabled`, `copy.format` and `systemItems` are ignored on macOS.
|
|
72
79
|
|
|
73
80
|
### Handling Copy in JS
|
|
@@ -84,6 +91,22 @@ clipboard library. See [`onCopy`](API_REFERENCE.md#oncopy).
|
|
|
84
91
|
/>
|
|
85
92
|
```
|
|
86
93
|
|
|
94
|
+
`source` says where the Copy came from:
|
|
95
|
+
|
|
96
|
+
| `source` | Copy item of |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `'selection'` | The text-selection menu |
|
|
99
|
+
| `'math'` | A block math long-press menu |
|
|
100
|
+
| `'table'` | A table long-press menu |
|
|
101
|
+
| `'code'` | A code block long-press menu |
|
|
102
|
+
| `'blockquote'` | A blockquote or admonition long-press menu (`flavor="github"`) |
|
|
103
|
+
|
|
104
|
+
For any `source` other than `'selection'`, `markdown` is the whole block's
|
|
105
|
+
Markdown, `text` is the block's raw content and `whole` is `true`. If you switch
|
|
106
|
+
over `source`, handle `'blockquote'` too; it was added when blockquotes and
|
|
107
|
+
admonitions got their own long-press menu. The code block header copy button is not routed
|
|
108
|
+
through `onCopy`; it keeps firing `onCopyPress`.
|
|
109
|
+
|
|
87
110
|
To turn the menu off entirely rather than item by item, use `contextMenuHidden`:
|
|
88
111
|
|
|
89
112
|
```tsx
|
|
@@ -94,8 +117,26 @@ To turn the menu off entirely rather than item by item, use `contextMenuHidden`:
|
|
|
94
117
|
The two are complementary: `selectionMenuConfig` prunes individual built-in
|
|
95
118
|
items and leaves the menu in place, while `contextMenuHidden` suppresses the
|
|
96
119
|
menu as a whole — including `contextMenuItems` and the copy menus on table,
|
|
97
|
-
code and
|
|
98
|
-
only; it does not affect
|
|
120
|
+
code, math and blockquote/admonition blocks. Note that `contextMenuHidden`
|
|
121
|
+
applies to `EnrichedMarkdownText` only; it does not affect
|
|
122
|
+
`EnrichedMarkdownTextInput`.
|
|
123
|
+
|
|
124
|
+
### `contextMenuHidden` vs `enableBlockContextMenu`
|
|
125
|
+
|
|
126
|
+
Both props can turn the block long-press menus off, but they do different
|
|
127
|
+
things, and `contextMenuHidden` wins when both are set:
|
|
128
|
+
|
|
129
|
+
| | `enableBlockContextMenu={false}` | `contextMenuHidden` |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| Text-selection menu | Unchanged | Hidden |
|
|
132
|
+
| Block long-press menu (code, table, math, blockquote/admonition) | Not shown | Not shown |
|
|
133
|
+
| Long-press on a block | No popup, no `onSelectionChange` event | Reported through `onSelectionChange` with the block's `source`, so you can show your own menu |
|
|
134
|
+
| `contextMenuItems` | Unchanged | Hidden |
|
|
135
|
+
|
|
136
|
+
So `contextMenuHidden` with `enableBlockContextMenu` left at its default `true`
|
|
137
|
+
still hides every block menu, and the long-press is still reported to JS.
|
|
138
|
+
Set only `enableBlockContextMenu={false}` when you want the system selection
|
|
139
|
+
menu but no block popups.
|
|
99
140
|
|
|
100
141
|
`EnrichedMarkdownTextInput` supports the same `{ enabled, label }` shape. In addition to `copyAsMarkdown`, the input's `selectionMenuConfig` exposes the built-in **Format** submenu, and `formatMenuConfig` controls the items inside it:
|
|
101
142
|
|
|
@@ -147,12 +188,14 @@ Notes:
|
|
|
147
188
|
required; any category left `undefined` falls back to it. The `{count}` token
|
|
148
189
|
is replaced by the number of selected images.
|
|
149
190
|
- The labels apply to the main text selection menu as well as the table, math,
|
|
150
|
-
|
|
191
|
+
code block, and blockquote/admonition copy menus. With `flavor="github"`, the code block header's copy
|
|
151
192
|
button also reuses the copy label for assistive technologies (the CommonMark
|
|
152
193
|
flavor renders code inline with no header button): it is the button's
|
|
153
194
|
contentDescription on Android, and on iOS it names the VoiceOver custom
|
|
154
195
|
action that triggers the copy. To be notified when code is copied from a code
|
|
155
|
-
block, use the [`onCopyPress`](./API_REFERENCE.md#oncopypress) callback
|
|
196
|
+
block, use the [`onCopyPress`](./API_REFERENCE.md#oncopypress) callback; to react
|
|
197
|
+
to a tap anywhere on a code block, use
|
|
198
|
+
[`onCodeBlockPress`](./API_REFERENCE.md#oncodeblockpress).
|
|
156
199
|
- OS-provided actions (Look Up, Translate…) and the system **Cut / Paste /
|
|
157
200
|
Select All** items are localized by the platform and are not affected by this
|
|
158
201
|
config.
|
|
@@ -12,13 +12,14 @@ Markdown elements in `react-native-enriched-markdown-scaffold` are organized int
|
|
|
12
12
|
|---------|--------|----------------|-------------|
|
|
13
13
|
| Headings | `# H1` to `###### H6` | `h1` - `h6` | Six levels of headings |
|
|
14
14
|
| Paragraphs | Plain text | `paragraph` | Default text container |
|
|
15
|
-
| Blockquotes | `> Quote` | `blockquote` | Quoted content with accent bar, unlimited nesting |
|
|
15
|
+
| Blockquotes | `> Quote` | `blockquote` | Quoted content with accent bar, unlimited nesting; with `flavor="github"` rendered as a recursive block container (own padding/background box, and quoted code blocks/tables become real nested block components) |
|
|
16
16
|
| Code Blocks | ` ``` code ``` ` | `codeBlock` | Multi-line code containers; with `flavor="github"` rendered as a block component with a language header and copy-code button |
|
|
17
17
|
| Unordered Lists | `- Item`, `* Item`, or `+ Item` | `list` | Bullet lists with unlimited nesting |
|
|
18
18
|
| Ordered Lists | `1. Item` | `list` | Numbered lists with unlimited nesting |
|
|
19
19
|
| Task Lists | `- [x] Done`, `- [ ] Todo` | `taskList` | Interactive checkboxes (requires `flavor="github"`) |
|
|
20
20
|
| Thematic Break | `---`, `***`, or `___` | `thematicBreak` | Horizontal rule separator |
|
|
21
21
|
| Images | `` | `image` | Block-level images with spacing |
|
|
22
|
+
| Videos | `<video src="url">` | `video` | Native video player via HTML `<video>` tag (requires `flavor="github"` and `enableVideo`) |
|
|
22
23
|
| Tables | `| col | col |` | `table` | GFM tables with alignment support (requires `flavor="github"`) |
|
|
23
24
|
| Math Block | `$$...$$` | `math` | Block-level LaTeX math (display equations) (requires `flavor="github"`) |
|
|
24
25
|
|
|
@@ -142,6 +143,23 @@ When displaying content authored in `EnrichedMarkdownTextInput`, pressing Enter
|
|
|
142
143
|
|
|
143
144
|
This forces the parser to treat every soft break as a hard break, so single newlines render as line breaks on all platforms.
|
|
144
145
|
|
|
146
|
+
### Blank Lines
|
|
147
|
+
|
|
148
|
+
By default, CommonMark collapses any run of consecutive blank lines between two blocks into a single paragraph break, so pressing Enter several times renders the same as pressing it once. To keep the extra spacing, enable the `preserveBlankLines` flag:
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
<EnrichedMarkdownText
|
|
152
|
+
markdown={markdownFromInput}
|
|
153
|
+
markdownStyle={{ paragraph: { marginTop: 0, marginBottom: 0 } }}
|
|
154
|
+
md4cFlags={{ preserveBlankLines: true }}
|
|
155
|
+
/>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Each blank line in the source renders as one empty line, so the output keeps the exact number of blank lines that were typed - four blank lines between two paragraphs render as four empty lines. This makes `EnrichedMarkdownText` reproduce content authored in `EnrichedMarkdownTextInput` line for line, which is useful for chat-style apps.
|
|
159
|
+
|
|
160
|
+
> [!NOTE]
|
|
161
|
+
> Paragraph margins stack on top of the blank-line spacing. Set `paragraph.marginTop` and `paragraph.marginBottom` to `0` in `markdownStyle` so that spacing is driven purely by blank lines; otherwise even a standard single-blank-line paragraph break will render with extra height.
|
|
162
|
+
|
|
145
163
|
## Images: Block vs Inline
|
|
146
164
|
|
|
147
165
|
Images are automatically detected as block or inline based on context:
|
|
@@ -151,6 +169,35 @@ Images are automatically detected as block or inline based on context:
|
|
|
151
169
|
|
|
152
170
|
You don't need to specify which type—the renderer automatically determines this based on the image's position in the content. Note that a single newline doesn't split a paragraph, so an image on its own source line directly below text is still inline; separate it with a blank line to make it a block image.
|
|
153
171
|
|
|
172
|
+
Images also render inside GFM table cells, following the same block/inline detection and honoring the `image` styles (`aspectRatio`, `maxHeight`, `height`).
|
|
173
|
+
|
|
174
|
+
## Videos
|
|
175
|
+
|
|
176
|
+
Videos are embedded using the standard HTML `<video>` tag, which is the most common way to include video in markdown:
|
|
177
|
+
|
|
178
|
+
```markdown
|
|
179
|
+
<video src="https://example.com/ocean.mp4"></video>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The parser recognizes block-level `<video>` tags and renders them as native video players. Other HTML tags are silently ignored — only `<video>` is allowlisted. Inline HTML remains disabled.
|
|
183
|
+
|
|
184
|
+
> **Note:** HTML attributes like `width`, `height`, `controls`, `autoplay`, etc. on the `<video>` tag are ignored — only `src` is used. All video styling (dimensions, aspect ratio, border radius, margins, background color) is controlled via the `markdownStyle.video` prop. See [Style Properties Reference](./STYLES.md#video-specific).
|
|
185
|
+
|
|
186
|
+
Video requires:
|
|
187
|
+
- `flavor="github"` for native segment rendering
|
|
188
|
+
- `enableVideo` in your app's `package.json` `"enriched-markdown"` config (enabled by default)
|
|
189
|
+
|
|
190
|
+
> [!NOTE]
|
|
191
|
+
> On Android, `enableVideo` compiles in Media3 ExoPlayer 1.6.0. Gradle picks one Media3 version for the
|
|
192
|
+
> whole app, so another library that brings its own Media3 (for example `expo-video`) can force a
|
|
193
|
+
> different version than the one this library was built against. If your app does not render videos in
|
|
194
|
+
> markdown, or already ships `expo-video`, set `"enableVideo": false` to leave Media3 out.
|
|
195
|
+
|
|
196
|
+
On iOS, videos render via `AVPlayerViewController`; on Android, via ExoPlayer (`PlayerView`). On web, videos render as `<video>` elements with native browser controls.
|
|
197
|
+
|
|
198
|
+
> [!NOTE]
|
|
199
|
+
> Videos inside **blockquotes** and **admonitions** are fully supported. Videos inside **lists** are currently promoted out of the list and rendered as standalone blocks above the remaining list items — the list bullet/marker is not shown for video items. This behavior may change in a future release.
|
|
200
|
+
|
|
154
201
|
## Nested Elements
|
|
155
202
|
|
|
156
203
|
Some elements support unlimited nesting depth with automatic indentation:
|