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/INPUT.md
CHANGED
|
@@ -207,9 +207,60 @@ Three inline constructs are still lossy in this mode, exactly as they are with
|
|
|
207
207
|
| Input | Saved as | Why |
|
|
208
208
|
| --- | --- | --- |
|
|
209
209
|
| `` gõ `x` vào `` | `gõ x vào` | The editor has no inline code style, so the backticks have nothing to round-trip through |
|
|
210
|
-
| `Giá 5\$` | `Giá 5$` | The serializer does not re-escape `\$`, which can leave an unpaired
|
|
210
|
+
| `Giá 5\$` | `Giá 5$` | The serializer does not re-escape `\$`, which can leave an unpaired `$`. See [Backslash escapes](#backslash-escapes) |
|
|
211
211
|
| `A & B` | `A B` | HTML entity nodes are dropped. A raw `&` is safe |
|
|
212
212
|
|
|
213
|
+
`markdownShortcuts` is forced off while `blockSyntax={false}`: a shortcut would turn a typed
|
|
214
|
+
`# ` or `- ` into structure and drop the marker, which breaks the byte-for-byte guarantee. See
|
|
215
|
+
[Markdown Shortcuts](#markdown-shortcuts).
|
|
216
|
+
|
|
217
|
+
## Markdown Shortcuts
|
|
218
|
+
|
|
219
|
+
With `markdownShortcuts` enabled, typing a markdown block prefix at the start of a paragraph and following it with a space converts the paragraph into that block and removes the prefix — the convention Notion, Bear, Obsidian and Apple Notes users expect:
|
|
220
|
+
|
|
221
|
+
| Typed | Becomes |
|
|
222
|
+
|---|---|
|
|
223
|
+
| `# ` … `###### ` | Heading 1 … 6 |
|
|
224
|
+
| `- `, `* `, `+ ` | Bullet list item |
|
|
225
|
+
| `1. `, `1) ` (any number) | Numbered list item |
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
<EnrichedMarkdownTextInput markdownShortcuts />
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
It is **off by default**: an app that treats `#` or `-` as literal text (tags, channel names, dashes) sees no change unless it opts in. Pass a config object to enable a subset — an omitted key is off:
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
<EnrichedMarkdownTextInput markdownShortcuts={{ heading: true }} />
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Behavior notes:
|
|
238
|
+
|
|
239
|
+
- The shortcut only fires on a **plain paragraph**. Typing `# ` inside an existing heading or list item leaves the text alone.
|
|
240
|
+
- It is a **typing** affordance: it converts only text that was inserted, so pasting `# Title`, typing over a selection or committing an autocorrection never reformats a line. Markdown that is loaded into the input is parsed as markdown already.
|
|
241
|
+
- The conversion goes through the same block pipeline as [`toggleHeading`](#headings) and the [list commands](#lists), so `onChangeState`, serialization and Return-continues-the-list behave exactly as if the block had been toggled from a toolbar.
|
|
242
|
+
- Backspace at the start of a freshly converted **list item** removes the marker again (the existing list Backspace rule). A converted heading is turned off with `toggleHeading` or by deleting the line.
|
|
243
|
+
- Without the shortcut a literal `# Heading` paragraph still serializes as `# Heading`, so it would become a heading the next time the markdown is loaded. Enabling shortcuts makes what the user sees while typing agree with what they get after a reload.
|
|
244
|
+
- Shortcuts are ignored when [`blockSyntax={false}`](#preserving-block-syntax): the JS wrapper always sends them as off in that mode, whatever `markdownShortcuts` says, so the typed prefix stays text and the round trip stays byte for byte.
|
|
245
|
+
|
|
246
|
+
## Backslash escapes
|
|
247
|
+
|
|
248
|
+
A backslash escape in loaded or pasted markdown (`\*`, `\_`, `\$`, `` \` ``, …) is consumed by the
|
|
249
|
+
parser on **both platforms**: the editor shows the literal character without the backslash, and the
|
|
250
|
+
backslash is not stored anywhere. This applies with `blockSyntax` on and off. (Before upstream v1.1.1,
|
|
251
|
+
iOS kept the backslash in the text while Android already dropped it; #798 aligned iOS with Android.)
|
|
252
|
+
|
|
253
|
+
The serializer does not add escapes back, so escaped markdown does **not** round-trip:
|
|
254
|
+
|
|
255
|
+
| Loaded | Shown in the editor | `onChangeMarkdown` |
|
|
256
|
+
| --- | --- | --- |
|
|
257
|
+
| `\*not italic\*` | `*not italic*` | `*not italic*` (italic the next time it is loaded) |
|
|
258
|
+
| `costs \$5 or \$6` | `costs $5 or $6` | `costs $5 or $6` (inline math the next time it is loaded) |
|
|
259
|
+
|
|
260
|
+
This is a known issue. If a literal `$` or `*` must survive a save and reload, keep it out of a
|
|
261
|
+
position where it pairs with another delimiter, or escape it again in your app before rendering.
|
|
262
|
+
|
|
263
|
+
|
|
213
264
|
## Caret Position Tracking
|
|
214
265
|
|
|
215
266
|
`EnrichedMarkdownTextInput` can report the caret's pixel position relative to the input, which is useful when the input is embedded in a scrollable container with `scrollEnabled={false}` and you need to keep the caret visible.
|
|
@@ -283,11 +334,13 @@ Because nothing is written until you resolve, an async decision is safe: the sel
|
|
|
283
334
|
| | Behavior |
|
|
284
335
|
| --- | --- |
|
|
285
336
|
| **iOS** | Context menu and hardware ⌘V. `markdown` is set when the copy source was an `EnrichedMarkdownTextInput`. |
|
|
286
|
-
| **Android** | Context menu, hardware Ctrl+V
|
|
337
|
+
| **Android** | Context menu, hardware Ctrl+V, `KEYCODE_PASTE`, and a keyboard clipboard chip (Gboard, Samsung Keyboard) — see below. `markdown` is always `''`, and `resolvePaste` inserts `text` verbatim — so an intercepted copy-then-paste inside the app lands as plain text, even though the un-intercepted paste restores the formatting. |
|
|
287
338
|
| **macOS** | `interceptPaste` is ignored, `onPaste` never fires, and pastes insert inline as usual. |
|
|
288
339
|
|
|
289
340
|
Only clipboard content is intercepted. Drag-and-drop, autofill and IME content insertion bypass `onPaste` on both platforms and insert normally — on Android they are filtered out explicitly, so an autofill never arrives looking like a paste.
|
|
290
341
|
|
|
342
|
+
On Android a keyboard clipboard chip does not paste through the menu: the keyboard types the text in through the input connection. The input reports it as a paste when the committed text is exactly the current clipboard text and is at least 16 characters long or spans more than one line. Shorter single-line chip pastes, entries from the keyboard's clipboard history other than the current clip, and text the keyboard changes on the way insert inline without `onPaste`.
|
|
343
|
+
|
|
291
344
|
## Style Detection
|
|
292
345
|
|
|
293
346
|
All of the above styles can be detected with the use of [onChangeState](API_REFERENCE.md#onchangestate) callback payload.
|
|
@@ -298,7 +351,7 @@ You can find some examples in the [usage section](#usage) or in the example app.
|
|
|
298
351
|
|
|
299
352
|
`EnrichedMarkdownTextInput` emits a few more events that may be of use:
|
|
300
353
|
|
|
301
|
-
- [onFocus](API_REFERENCE.md#onfocus
|
|
354
|
+
- [onFocus](API_REFERENCE.md#onfocus) - emits whenever input focuses.
|
|
302
355
|
- [onBlur](API_REFERENCE.md#onblur) - emits whenever input blurs.
|
|
303
356
|
- [onChangeText](API_REFERENCE.md#onchangetext) - returns the input's plain text (without Markdown syntax) anytime it changes.
|
|
304
357
|
- [onChangeMarkdown](API_REFERENCE.md#onchangemarkdown) - returns the Markdown string parsed from current input text and styles anytime it would change. As parsing the Markdown on each input change can be expensive, not assigning the event's callback will skip the serialization for better performance.
|
|
@@ -376,3 +429,7 @@ Available style properties:
|
|
|
376
429
|
(`$...$`) at bold weight. See [LATEX_MATH.md](./LATEX_MATH.md#bold-formulas).
|
|
377
430
|
- `math.fontWeight` — same for block formula chips (`$$...$$`); inherits from
|
|
378
431
|
`inlineMath.fontWeight` when unset.
|
|
432
|
+
|
|
433
|
+
> [!NOTE]
|
|
434
|
+
> Block formula chips (`$$...$$`) are typeset in display style on Android and in inline style on
|
|
435
|
+
> iOS. This is a known platform difference; see [LaTeX Math](LATEX_MATH.md#styling-math-in-the-editor).
|
package/docs/LATEX_MATH.md
CHANGED
|
@@ -80,6 +80,14 @@ the caret, selection and IME step over a formula in one move — and it is why
|
|
|
80
80
|
reports the `$...$` source. Offsets in `onChangeSelection`, `onCaretRectChange` and
|
|
81
81
|
`updateMath` / `removeMath` count a formula as that one character.
|
|
82
82
|
|
|
83
|
+
> [!NOTE]
|
|
84
|
+
> **Known difference: `$$...$$` chips in the editor.** On Android a block chip (`$$...$$`) is typeset
|
|
85
|
+
> in display style (large operators, limits above and below `\sum` / `\int`, full-size fractions),
|
|
86
|
+
> matching how `EnrichedMarkdownText` renders block math. On iOS the same chip is typeset in inline
|
|
87
|
+
> (text) style, like a `$...$` chip, so it is shorter and its limits sit beside the operator. The
|
|
88
|
+
> chip's styling keys (`math.*`) and the serialized `$$...$$` source are the same on both platforms;
|
|
89
|
+
> only the typesetting style differs.
|
|
90
|
+
|
|
83
91
|
### Bold formulas
|
|
84
92
|
|
|
85
93
|
`math.fontWeight` / `inlineMath.fontWeight` (`'normal'` | `'bold'`, default `'normal'`) typeset a
|
|
@@ -128,6 +136,28 @@ iOS + Android only; there is no web or macOS chip surface.
|
|
|
128
136
|
> [!IMPORTANT]
|
|
129
137
|
> LaTeX commands use backslashes (e.g. `\frac`, `\alpha`). In regular JS strings and template literals, backslashes are escape characters. Use `String.raw` or double backslashes (`\\frac`) to preserve them. Block math (`$$...$$`) must be on its own line to render as a display element.
|
|
130
138
|
|
|
139
|
+
## Detecting render failures
|
|
140
|
+
|
|
141
|
+
When the engine cannot draw a formula (an unsupported command, a syntax error) it falls back to showing the raw source instead of crashing. The [`onLatexError`](API_REFERENCE.md#onlatexerror) callback lets you observe these failures - for example to report them to an error tracker:
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
<EnrichedMarkdownText
|
|
145
|
+
markdown={"Inline $\\foo$ and block:\n\n$$\\bar$$"}
|
|
146
|
+
onLatexError={({ source, message, displayMode }) => {
|
|
147
|
+
reportToErrorTracker('latex-render-failed', { source, message, displayMode });
|
|
148
|
+
}}
|
|
149
|
+
/>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The whole expression is the unit of failure: the engine either renders an expression in full or rejects it, so `source` is the entire failing inline span or block (no `$`/`$$` delimiters) rather than a single command. `displayMode` is `false` for inline `$...$` and `true` for block `$$...$$`. This is native-only (iOS and Android); on web, unsupported LaTeX falls back to the raw source without a callback.
|
|
153
|
+
|
|
154
|
+
### De-duplication and re-mounts
|
|
155
|
+
|
|
156
|
+
Each `EnrichedMarkdownText` instance remembers the failures it has already reported (keyed by `displayMode` + `source`) and fires `onLatexError` **at most once per distinct failing expression** for its lifetime. The cache is not cleared when the `markdown` prop changes, so streaming content - where the same expressions are re-parsed on every update - reports each failure only once instead of on every keystroke or token.
|
|
157
|
+
|
|
158
|
+
> [!CAUTION]
|
|
159
|
+
> The de-duplication is per component **instance**, not global. If the component unmounts and remounts (a new instance - e.g. navigating away and back, changing its React `key`, or list virtualization recycling it), the fresh instance has no memory of prior reports and will fire `onLatexError` again for the same expressions. If you forward these to an error tracker, de-duplicate on your side as well (e.g. by `source`) so a remount does not inflate your counts.
|
|
160
|
+
|
|
131
161
|
## Web
|
|
132
162
|
|
|
133
163
|
On web the library renders LaTeX via [KaTeX](https://katex.org/) in **MathML output mode**. Browsers render MathML natively — no CSS or font files are required.
|
package/docs/MACOS.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`react-native-enriched-markdown-scaffold` supports macOS via [react-native-macos](https://github.com/microsoft/react-native-macos). The native layer shares code with iOS through a platform abstraction header (`ENRMUIKit.h`), with macOS-specific implementations for context menus, text selection, and clipboard handling.
|
|
4
4
|
|
|
5
|
-
The macOS implementation supports the same rendering elements as iOS — CommonMark, GitHub Flavored Markdown (tables, task lists, strikethrough), images, code blocks, blockquotes, and all other supported elements. `EnrichedMarkdownTextInput` is also available on macOS with full support for inline styles, links, and the native context menu.
|
|
5
|
+
The macOS implementation supports the same rendering elements as iOS — CommonMark, GitHub Flavored Markdown (tables, task lists, strikethrough), images, code blocks, blockquotes, video playback, and all other supported elements. `EnrichedMarkdownTextInput` is also available on macOS with full support for inline styles, links, and the native context menu.
|
|
6
6
|
|
|
7
7
|
## Known limitations
|
|
8
8
|
|
package/docs/MENTIONS.md
CHANGED
|
@@ -73,10 +73,10 @@ Each key is a regex tested against the link URL. First match wins. Patterns are
|
|
|
73
73
|
|
|
74
74
|
Inheritance from the base `link` style is split in two groups:
|
|
75
75
|
|
|
76
|
-
- **Text** (`color`, `underline`): unspecified properties inherit from `link`.
|
|
76
|
+
- **Text** (`color`, `underline`, `fontFamily`): unspecified properties inherit from `link`. `fontFamily` can be overridden per variant and otherwise inherits the base `link` family.
|
|
77
77
|
- **Box** (`backgroundColor`, `borderRadius`, `paddingHorizontal`, `paddingVertical`, `borderColor`, `borderWidth`): never inherited. A variant that sets none of them renders without a chip, even when `link` is a chip.
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
See [Link chips](STYLES.md#link-chips) for the box properties.
|
|
80
80
|
|
|
81
81
|
## Positioning the Suggestion List
|
|
82
82
|
|
package/docs/STYLES.md
CHANGED
|
@@ -165,6 +165,11 @@ The library provides sensible default styles for all Markdown elements out of th
|
|
|
165
165
|
borderRadius: 8,
|
|
166
166
|
marginBottom: 12,
|
|
167
167
|
},
|
|
168
|
+
video: {
|
|
169
|
+
borderRadius: 12,
|
|
170
|
+
aspectRatio: 16 / 9,
|
|
171
|
+
backgroundColor: '#000000',
|
|
172
|
+
},
|
|
168
173
|
inlineImage: {
|
|
169
174
|
size: 20,
|
|
170
175
|
},
|
|
@@ -283,6 +288,14 @@ function App() {
|
|
|
283
288
|
| `marginBottom` | `number` | Bottom margin |
|
|
284
289
|
| `lineHeight` | `number` | Line height |
|
|
285
290
|
|
|
291
|
+
> [!NOTE]
|
|
292
|
+
> **`lineHeight` behavior (this fork differs from upstream):** text-only lines are **clamped** to `lineHeight`: a line is laid out at exactly `lineHeight`, even when that is smaller than the font's natural line height. This matches React Native's core `<Text>` and keeps containers that size themselves as `lineHeight × N` lines exact. Only lines that hold self-measuring content use `lineHeight` as a floor and grow to fit it instead of clipping it:
|
|
293
|
+
>
|
|
294
|
+
> - **iOS:** a block (paragraph, heading, list item, blockquote paragraph) that contains inline math or a block image uses `lineHeight` as a floor for all of its lines. Every other block is clamped (`minimumLineHeight = maximumLineHeight = lineHeight`). Fenced code blocks are always clamped.
|
|
295
|
+
> - **Android:** the decision is per line. A line that contains a self-measuring replacement span (inline math, the placeholder used to measure it, or an emoji the system font lacks and EmojiCompat draws) is only expanded, never compressed. Every other line, including lines whose only tall content is large inline `code`, is clamped. Block images are excluded from the span entirely.
|
|
296
|
+
>
|
|
297
|
+
> Upstream v1.1.1 (#740 Android, #832 iOS) changed `lineHeight` to a floor for every line, so a `lineHeight` below the font's natural line height renders at the natural height. The fork keeps the clamp because consumers set `lineHeight` below the natural height of fonts with tall metrics (for example Baloo 2, ~1.6em) and rely on exact line counts. The cost: on text-only lines, glyphs taller than `lineHeight` (large inline `code`, emoji on iOS, or scripts taller than the Latin baseline such as Thai) can overlap the neighbouring line or be clipped at the component's top and bottom edges. If you need the upstream floor, set `lineHeight` at or above the font's natural line height (about `fontSize × 1.2` for system fonts, higher for fonts with tall ascenders).
|
|
298
|
+
|
|
286
299
|
### Paragraph and Heading-specific (paragraph, h1-h6)
|
|
287
300
|
|
|
288
301
|
| Property | Type | Description |
|
|
@@ -462,6 +475,20 @@ Styles for highlighted text (`==text==`). Requires `md4cFlags={{ highlight: true
|
|
|
462
475
|
|
|
463
476
|
> Sizing precedence: `aspectRatio` > `maxHeight` > `height`. `resizeMode` applies independently on top. When no new knob is set (`resizeMode`, `maxHeight`, or `aspectRatio`), block images keep the exact legacy fixed-`height` behavior.
|
|
464
477
|
|
|
478
|
+
### Video-specific
|
|
479
|
+
|
|
480
|
+
Styles for block-level videos embedded via the HTML `<video>` tag (e.g. `<video src="url"></video>`). Requires `flavor="github"` and the `enableVideo` opt-in in your app's `package.json`.
|
|
481
|
+
|
|
482
|
+
| Property | Type | Description |
|
|
483
|
+
|----------|------|-------------|
|
|
484
|
+
| `marginTop` | `number` | Top margin |
|
|
485
|
+
| `marginBottom` | `number` | Bottom margin |
|
|
486
|
+
| `borderRadius` | `number` | Corner radius |
|
|
487
|
+
| `aspectRatio` | `number` | Width / height ratio (e.g. `16 / 9`). The video fills the available width and its height is derived from this ratio. Must be positive; defaults to `16 / 9` |
|
|
488
|
+
| `backgroundColor` | `string` | Fill color behind the video element, visible before the video loads or in letterboxing areas |
|
|
489
|
+
|
|
490
|
+
Videos render as native player views — `AVPlayerViewController` on iOS and ExoPlayer (`PlayerView`) on Android. Playback controls are provided by the native player and appear automatically.
|
|
491
|
+
|
|
465
492
|
### Inline Image-specific
|
|
466
493
|
|
|
467
494
|
| Property | Type | Description |
|
package/docs/TEXT.md
CHANGED
|
@@ -97,6 +97,14 @@ See the [API Reference](API_REFERENCE.md#onlinkpress) for detailed examples and
|
|
|
97
97
|
|
|
98
98
|
Links can be styled as chips (background, radius, padding, border — see [Link chips](STYLES.md#link-chips)) and decorated with your own views via [`renderLinkDecoration`](API_REFERENCE.md#renderlinkdecoration).
|
|
99
99
|
|
|
100
|
+
### Image Handling
|
|
101
|
+
|
|
102
|
+
Rendered images can be made interactive with the `onImagePress` callback, which receives the image `url` and `altText`. Use it to open a lightbox or full-screen viewer. It fires for block and inline images (including those in headings, lists, and blockquotes); an image that is also a link keeps link behavior and fires `onLinkPress` instead. See the [API Reference](API_REFERENCE.md#onimagepress) for details.
|
|
103
|
+
|
|
104
|
+
### Code Block Handling
|
|
105
|
+
|
|
106
|
+
A fenced code block can be made tappable with the `onCodeBlockPress` callback, which receives the block's `code` and `language`. Use it to build actions like copy-to-clipboard or opening the code in a viewer. A tap anywhere in the block body fires it, while text selection, the header copy button (GitHub flavor), and the long-press menu stay unchanged. Works in both the CommonMark and GitHub flavors, and on web (where the code block is a clickable, keyboard-activatable element). See the [API Reference](API_REFERENCE.md#oncodeblockpress) for details.
|
|
107
|
+
|
|
100
108
|
## Supported Markdown Elements
|
|
101
109
|
|
|
102
110
|
`react-native-enriched-markdown-scaffold` supports a comprehensive set of Markdown elements. See [Element Structure](ELEMENTS_STRUCTURE.md) for a detailed overview of all supported elements, their syntax, block vs inline categorization, nesting behavior, and how elements inherit typography from their parent blocks.
|
package/docs/WEB.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Web Support
|
|
2
2
|
|
|
3
|
-
`EnrichedMarkdownText` runs on web using
|
|
3
|
+
`EnrichedMarkdownText` runs on web using plain React and DOM primitives — **no `react-native-web` dependency required**. It works in any React project (Next.js, Vite, Remix, CRA, etc.).
|
|
4
|
+
|
|
5
|
+
Markdown parsing is handled by [md4c](https://github.com/mity/md4c) compiled to WebAssembly. The WASM binary is inlined as base64 inside the bundle (`SINGLE_FILE=1`), so there is no separate `.wasm` file to serve and no build step required by consumers — just import the component and it works.
|
|
4
6
|
|
|
5
7
|
The web renderer uses semantic HTML elements (`<p>`, `<h1>`–`<h6>`, `<blockquote>`, `<ul>`, `<ol>`, `<table>`, etc.) for improved accessibility.
|
|
6
8
|
|
|
@@ -10,9 +12,12 @@ All core `EnrichedMarkdownText` features are supported on web, including:
|
|
|
10
12
|
|
|
11
13
|
- Full GFM: tables (with horizontal scroll), task lists (with checkbox interaction), strikethrough, links, images (block and inline), code blocks, LaTeX math (block and inline)
|
|
12
14
|
- All `markdownStyle` customisation options
|
|
13
|
-
- `onLinkPress`, `onLinkLongPress` (mapped to `contextmenu` event), `onTaskListItemPress` callbacks
|
|
15
|
+
- `onLinkPress`, `onLinkLongPress` (mapped to `contextmenu` event), `onImagePress`, `onTaskListItemPress`, `onCodeBlockPress` callbacks
|
|
16
|
+
- `renderLinkDecoration` — overlays a React node on each link, anchored to the link's inline box
|
|
17
|
+
- `onImagePress` — makes rendered images focusable and keyboard-activatable (Enter/Space) with a button role; the browser's right-click menu is preserved
|
|
18
|
+
- `onCodeBlockPress` — makes fenced code blocks clickable and keyboard-activatable (Enter/Space) with a button role, receiving the block's `code` and `language`; clicking while code text is selected does not fire
|
|
14
19
|
- `enableTaskListItemToggle` — set to `false` to render task list checkboxes read-only (the click is fully inert: no toggle, no `onTaskListItemPress`). The checkbox keeps its normal appearance, marked `readOnly` / `aria-disabled` and pointer-inert rather than `disabled`, matching iOS and Android
|
|
15
|
-
- `allowTrailingMargin`, `containerStyle`, `selectable`, `selectionColor`, `md4cFlags` (`underline`, `superscript`, `subscript`, `latexMath`, `highlight`, `hardSoftBreaks`)
|
|
20
|
+
- `allowTrailingMargin`, `containerStyle`, `selectable`, `selectionColor`, `md4cFlags` (`underline`, `superscript`, `subscript`, `latexMath`, `highlight`, `hardSoftBreaks`, `preserveBlankLines`)
|
|
16
21
|
- RTL support via the `dir` prop (CSS logical properties automatically flip blockquote borders, list indentation, etc.)
|
|
17
22
|
|
|
18
23
|
### Accessibility
|
|
@@ -23,16 +28,23 @@ All core `EnrichedMarkdownText` features are supported on web, including:
|
|
|
23
28
|
- Math (KaTeX fallback): `role="math"` and `aria-label` with the expression content
|
|
24
29
|
- Task list checkboxes: `aria-label` with the task text (e.g. `"Task: Buy groceries"`)
|
|
25
30
|
|
|
26
|
-
### Web
|
|
31
|
+
### Web props
|
|
27
32
|
|
|
28
33
|
| Prop | Description |
|
|
29
34
|
|---|---|
|
|
30
|
-
| `dir` | Sets the text direction on the root container (`'ltr'`, `'rtl'`, or `'auto'`). CSS logical properties in the renderers automatically flip layout for RTL. |
|
|
35
|
+
| `dir` | Web-only. Sets the text direction on the root container (`'ltr'`, `'rtl'`, or `'auto'`). CSS logical properties in the renderers automatically flip layout for RTL. |
|
|
36
|
+
| `testID` | Standard React Native prop; on web it is applied to the root container as `data-testid`. |
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
All of these are part of the exported `EnrichedMarkdownTextProps` type for web.
|
|
33
39
|
|
|
34
40
|
## Ignored props (native-only)
|
|
35
41
|
|
|
42
|
+
These props belong to the iOS/Android API and have no effect on web. Because a
|
|
43
|
+
cross-platform project is usually type-checked against the native prop interface,
|
|
44
|
+
the same JSX compiles for web; these props are stripped before the root element
|
|
45
|
+
is rendered, so they never reach the DOM or trigger React "unknown prop"
|
|
46
|
+
warnings.
|
|
47
|
+
|
|
36
48
|
| Prop | Reason |
|
|
37
49
|
|---|---|
|
|
38
50
|
| `flavor` | The web renderer always uses full GFM capabilities. On native, `flavor` controls whether a single `TextView` (CommonMark) or container-based renderer (GitHub) is used; the DOM has no such constraint. |
|
|
@@ -41,10 +53,32 @@ The web implementation also exports `WebMarkdownTextProps` which extends `Enrich
|
|
|
41
53
|
| `allowFontScaling` / `maxFontSizeMultiplier` | React Native text scaling props. Browsers handle font scaling natively via OS accessibility settings. |
|
|
42
54
|
| `streamingAnimation` | Native-only tail fade-in animation. Not yet implemented on web. |
|
|
43
55
|
| `streamingConfig` | Native-only streaming table configuration. Not yet implemented on web. |
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
56
|
+
| `numberOfLines` / `ellipsizeMode` | Native text truncation. Not yet implemented on web. |
|
|
57
|
+
| `spoilerOverlay` | Native-only spoiler reveal animation. Not yet implemented on web. |
|
|
58
|
+
| `contextMenuItems` | Not supported - browsers don't allow extending the native context menu. |
|
|
59
|
+
| `selectionMenuConfig` | Not supported - native-only built-in selection menu actions. |
|
|
60
|
+
| `contextMenuHidden` | Not supported - browsers own the context menu on selected text. |
|
|
61
|
+
| `onSelectionChange` | Native-only selection tracking. On web, listen to the DOM `selectionchange` event instead. |
|
|
62
|
+
| `selectionHandleColor` | Android-only - desktop browsers don't render selection handles. |
|
|
63
|
+
| `imageRequestHeaders` | Not supported - browsers don't allow custom headers on `<img>` requests. |
|
|
64
|
+
| `accessibilityLabels` | VoiceOver / TalkBack announcement strings. The web renderer uses semantic HTML and native `aria-*` instead. |
|
|
65
|
+
| `textBreakStrategy` / `lineBreakStrategyIOS` / `writingDirection` | Native line-breaking and paragraph-direction controls. Use `dir` for web text direction. |
|
|
66
|
+
| `enableBlockContextMenu` | Native-only long-press copy popup on block views. |
|
|
67
|
+
| `onCopyPress` / `onLatexError` | Native-only callbacks. |
|
|
68
|
+
|
|
69
|
+
`onCopy` is not in this list because it is also a DOM prop: on web it is not the native `CopyEvent`
|
|
70
|
+
API, it reaches the root `div` as the DOM `copy` clipboard event.
|
|
71
|
+
|
|
72
|
+
`renderLinkDecoration` **is** supported on web (it is not in this list). The callback receives the
|
|
73
|
+
same `LinkDecorationInfo` shape as on native, but `rect` is the link's inline box and `rects` is
|
|
74
|
+
always `[rect]`.
|
|
75
|
+
|
|
76
|
+
The stripping covers this library's own props only. Generic React Native
|
|
77
|
+
`ViewProps` that the native interface inherits - `accessibilityLabel`,
|
|
78
|
+
`onLayout`, `pointerEvents`, `hitSlop`, `nativeID` and friends - are still
|
|
79
|
+
forwarded to the root element and will produce React "unknown prop" warnings on
|
|
80
|
+
web. Use the DOM equivalents (`aria-label`, `id`, CSS) instead. `testID` is the
|
|
81
|
+
exception: it is mapped to `data-testid`.
|
|
48
82
|
|
|
49
83
|
## Not supported on web
|
|
50
84
|
|