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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/web/types.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
package/postinstall.mjs
CHANGED
|
@@ -119,6 +119,13 @@ if (!enableMath) {
|
|
|
119
119
|
console.warn(`${LOG} WARNING: vendor-ratex failed. iOS math rendering may not work.`);
|
|
120
120
|
failed = true;
|
|
121
121
|
}
|
|
122
|
+
} else {
|
|
123
|
+
// Math is on (explicitly or by default) but the vendor script or its manifest is
|
|
124
|
+
// absent, so nothing was downloaded. Never fall through silently -- the iOS build
|
|
125
|
+
// would otherwise just quietly ship without math. Warn like any other failure.
|
|
126
|
+
console.warn(`${LOG} WARNING: math is enabled but the RaTeX vendor script or manifest is missing ` +
|
|
127
|
+
`(${vendorRatex}, ${ratexManifest}); iOS math rendering will be unavailable.`);
|
|
128
|
+
failed = true;
|
|
122
129
|
}
|
|
123
130
|
|
|
124
131
|
if (failed) {
|
|
@@ -27,6 +27,19 @@ interface HeadingStyleInternal extends BaseBlockStyleInternal {
|
|
|
27
27
|
textAlign: string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
interface AdmonitionColorsInternal {
|
|
31
|
+
color: ColorValue;
|
|
32
|
+
backgroundColor: ColorValue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface AdmonitionsStyleInternal {
|
|
36
|
+
note: AdmonitionColorsInternal;
|
|
37
|
+
tip: AdmonitionColorsInternal;
|
|
38
|
+
important: AdmonitionColorsInternal;
|
|
39
|
+
warning: AdmonitionColorsInternal;
|
|
40
|
+
caution: AdmonitionColorsInternal;
|
|
41
|
+
}
|
|
42
|
+
|
|
30
43
|
interface BlockquoteStyleInternal extends BaseBlockStyleInternal {
|
|
31
44
|
borderColor: ColorValue;
|
|
32
45
|
borderWidth: CodegenTypes.Float;
|
|
@@ -34,6 +47,7 @@ interface BlockquoteStyleInternal extends BaseBlockStyleInternal {
|
|
|
34
47
|
backgroundColor: ColorValue;
|
|
35
48
|
borderRadius: CodegenTypes.Float;
|
|
36
49
|
padding: CodegenTypes.Float;
|
|
50
|
+
admonitions: AdmonitionsStyleInternal;
|
|
37
51
|
}
|
|
38
52
|
|
|
39
53
|
interface ListStyleInternal extends BaseBlockStyleInternal {
|
|
@@ -96,6 +110,7 @@ interface LinkVariantEntryInternal {
|
|
|
96
110
|
paddingVertical: CodegenTypes.Float;
|
|
97
111
|
borderColor: ColorValue;
|
|
98
112
|
borderWidth: CodegenTypes.Float;
|
|
113
|
+
fontFamily: string;
|
|
99
114
|
}
|
|
100
115
|
|
|
101
116
|
interface StrongStyleInternal {
|
|
@@ -136,6 +151,14 @@ interface ImageStyleInternal {
|
|
|
136
151
|
marginBottom: CodegenTypes.Float;
|
|
137
152
|
}
|
|
138
153
|
|
|
154
|
+
interface VideoStyleInternal {
|
|
155
|
+
marginTop: CodegenTypes.Float;
|
|
156
|
+
marginBottom: CodegenTypes.Float;
|
|
157
|
+
borderRadius: CodegenTypes.Float;
|
|
158
|
+
aspectRatio: CodegenTypes.Float;
|
|
159
|
+
backgroundColor: ColorValue;
|
|
160
|
+
}
|
|
161
|
+
|
|
139
162
|
interface InlineImageStyleInternal {
|
|
140
163
|
size: CodegenTypes.Float;
|
|
141
164
|
}
|
|
@@ -240,6 +263,7 @@ export interface MarkdownStyleInternal {
|
|
|
240
263
|
underline: UnderlineStyleInternal;
|
|
241
264
|
code: CodeStyleInternal;
|
|
242
265
|
image: ImageStyleInternal;
|
|
266
|
+
video: VideoStyleInternal;
|
|
243
267
|
inlineImage: InlineImageStyleInternal;
|
|
244
268
|
thematicBreak: ThematicBreakStyleInternal;
|
|
245
269
|
table: TableStyleInternal;
|
|
@@ -280,9 +304,9 @@ export interface LinkLayoutEvent {
|
|
|
280
304
|
}
|
|
281
305
|
|
|
282
306
|
/**
|
|
283
|
-
* Current text selection, or a long-pressed table / math / code
|
|
284
|
-
* `contextMenuHidden` is on. `active: false` means the selection
|
|
285
|
-
* (every other field is then empty / zero). Rects are in dp / pt, relative to
|
|
307
|
+
* Current text selection, or a long-pressed table / math / code / blockquote
|
|
308
|
+
* block while `contextMenuHidden` is on. `active: false` means the selection
|
|
309
|
+
* was cleared (every other field is then empty / zero). Rects are in dp / pt, relative to
|
|
286
310
|
* the native view's origin; rect objects are written inline because codegen
|
|
287
311
|
* only accepts inline object literals in event payloads.
|
|
288
312
|
*/
|
|
@@ -313,6 +337,11 @@ export interface SelectionChangeEvent {
|
|
|
313
337
|
adjusting: boolean;
|
|
314
338
|
}
|
|
315
339
|
|
|
340
|
+
export interface ImagePressEvent {
|
|
341
|
+
url: string;
|
|
342
|
+
altText: string;
|
|
343
|
+
}
|
|
344
|
+
|
|
316
345
|
export interface TaskListItemPressEvent {
|
|
317
346
|
index: CodegenTypes.Int32;
|
|
318
347
|
checked: boolean;
|
|
@@ -325,13 +354,24 @@ export interface CopyPressEvent {
|
|
|
325
354
|
}
|
|
326
355
|
|
|
327
356
|
export interface CopyRequestEvent {
|
|
328
|
-
// 'selection' | 'math' | 'table' | 'code'
|
|
357
|
+
// 'selection' | 'math' | 'table' | 'code' | 'blockquote'
|
|
329
358
|
source: string;
|
|
330
359
|
markdown: string;
|
|
331
360
|
text: string;
|
|
332
361
|
whole: boolean;
|
|
333
362
|
}
|
|
334
363
|
|
|
364
|
+
export interface LatexErrorEvent {
|
|
365
|
+
source: string;
|
|
366
|
+
message: string;
|
|
367
|
+
displayMode: boolean;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export interface CodeBlockPressEvent {
|
|
371
|
+
code: string;
|
|
372
|
+
language: string;
|
|
373
|
+
}
|
|
374
|
+
|
|
335
375
|
export interface ContextMenuItemConfig {
|
|
336
376
|
text: string;
|
|
337
377
|
icon?: string;
|
|
@@ -438,6 +478,17 @@ export interface Md4cFlagsInternal {
|
|
|
438
478
|
* @default false
|
|
439
479
|
*/
|
|
440
480
|
hardSoftBreaks: boolean;
|
|
481
|
+
/**
|
|
482
|
+
* Preserve runs of consecutive blank lines as extra empty lines.
|
|
483
|
+
* @default false
|
|
484
|
+
*/
|
|
485
|
+
preserveBlankLines: boolean;
|
|
486
|
+
/**
|
|
487
|
+
* Enable GitHub-style admonitions/alerts extension.
|
|
488
|
+
* Forced off for `flavor="commonmark"`.
|
|
489
|
+
* @default true
|
|
490
|
+
*/
|
|
491
|
+
admonitions: boolean;
|
|
441
492
|
}
|
|
442
493
|
|
|
443
494
|
interface StreamingConfigInternal {
|
|
@@ -492,6 +543,22 @@ export interface NativeProps extends ViewProps {
|
|
|
492
543
|
* deduplicated, and `active: false` once the selection is gone.
|
|
493
544
|
*/
|
|
494
545
|
onSelectionChange?: CodegenTypes.DirectEventHandler<SelectionChangeEvent>;
|
|
546
|
+
/**
|
|
547
|
+
* Callback fired when a rendered image is tapped.
|
|
548
|
+
* Receives the image URL and its alt text (empty string when the image has
|
|
549
|
+
* no alt text). Images that are also links keep link behavior and emit
|
|
550
|
+
* `onLinkPress` instead, so a single tap never fires both.
|
|
551
|
+
*/
|
|
552
|
+
onImagePress?: CodegenTypes.BubblingEventHandler<ImagePressEvent>;
|
|
553
|
+
/**
|
|
554
|
+
* Gates native image tap handling. Set automatically to `true` by the JS
|
|
555
|
+
* wrapper when `onImagePress` is provided. When `false` (default), images are
|
|
556
|
+
* inert: taps fall through to text selection and the iOS Copy/Save menu
|
|
557
|
+
* exactly as before, and no image span becomes interactive on Android.
|
|
558
|
+
*
|
|
559
|
+
* @default false
|
|
560
|
+
*/
|
|
561
|
+
enableImagePress?: CodegenTypes.WithDefault<boolean, false>;
|
|
495
562
|
/**
|
|
496
563
|
* Callback fired when a task list checkbox is tapped.
|
|
497
564
|
* Receives the 0-based task index, current checked state, and the item's plain text.
|
|
@@ -512,6 +579,30 @@ export interface NativeProps extends ViewProps {
|
|
|
512
579
|
* action. Receives the copied code and its language.
|
|
513
580
|
*/
|
|
514
581
|
onCopyPress?: CodegenTypes.BubblingEventHandler<CopyPressEvent>;
|
|
582
|
+
/** Fired when a fenced code block is tapped. Receives its code and language. */
|
|
583
|
+
onCodeBlockPress?: CodegenTypes.BubblingEventHandler<CodeBlockPressEvent>;
|
|
584
|
+
/**
|
|
585
|
+
* Gates native code block tap handling; set to `true` by the JS wrapper when
|
|
586
|
+
* `onCodeBlockPress` is provided.
|
|
587
|
+
* @default false
|
|
588
|
+
*/
|
|
589
|
+
enableCodeBlockPress?: CodegenTypes.WithDefault<boolean, false>;
|
|
590
|
+
/**
|
|
591
|
+
* Callback fired when a math expression cannot be parsed or rendered by the
|
|
592
|
+
* LaTeX engine. Receives the raw LaTeX `source` of the failing inline span or
|
|
593
|
+
* block (no delimiters), the engine's error `message` (empty when none), and
|
|
594
|
+
* `displayMode` (false = inline `$...$`, true = block `$$...$$`). The whole
|
|
595
|
+
* expression is the unit of failure; the engine does not report a single
|
|
596
|
+
* offending command.
|
|
597
|
+
*/
|
|
598
|
+
onLatexError?: CodegenTypes.BubblingEventHandler<LatexErrorEvent>;
|
|
599
|
+
/**
|
|
600
|
+
* Controls the long-press copy menu on code blocks, tables, block math, and blockquotes/admonitions.
|
|
601
|
+
* `contextMenuHidden` takes precedence: when it is true no block menu is
|
|
602
|
+
* shown regardless of this flag.
|
|
603
|
+
* @default true
|
|
604
|
+
*/
|
|
605
|
+
enableBlockContextMenu?: CodegenTypes.WithDefault<boolean, true>;
|
|
515
606
|
/**
|
|
516
607
|
* Fired instead of writing the clipboard when the Copy item of the text
|
|
517
608
|
* selection menu or a table / math / code block menu is pressed while
|
|
@@ -569,6 +660,8 @@ export interface NativeProps extends ViewProps {
|
|
|
569
660
|
* Controls how the markdown parser interprets certain syntax.
|
|
570
661
|
*/
|
|
571
662
|
md4cFlags: Md4cFlagsInternal;
|
|
663
|
+
/** Enables the GFM table, strikethrough, and task-list extensions. */
|
|
664
|
+
isGFM?: CodegenTypes.WithDefault<boolean, true>;
|
|
572
665
|
/**
|
|
573
666
|
* Specifies whether fonts should scale to respect Text Size accessibility settings.
|
|
574
667
|
* When false, text will not scale with the user's accessibility settings.
|
|
@@ -653,6 +746,19 @@ export interface NativeProps extends ViewProps {
|
|
|
653
746
|
* @platform ios
|
|
654
747
|
*/
|
|
655
748
|
writingDirection?: CodegenTypes.WithDefault<string, 'first-strong'>;
|
|
749
|
+
/**
|
|
750
|
+
* No-op for the GFM backend. Declared for parity with the CommonMark
|
|
751
|
+
* component so the shared JS props can be forwarded uniformly. GFM renders
|
|
752
|
+
* independent block segments and cannot honor a document-wide line cap, so
|
|
753
|
+
* this is ignored - see the GFM tracking issue.
|
|
754
|
+
* @default 0
|
|
755
|
+
*/
|
|
756
|
+
numberOfLines?: CodegenTypes.WithDefault<CodegenTypes.Int32, 0>;
|
|
757
|
+
/**
|
|
758
|
+
* No-op for the GFM backend. See `numberOfLines`.
|
|
759
|
+
* @default 'tail'
|
|
760
|
+
*/
|
|
761
|
+
ellipsizeMode?: CodegenTypes.WithDefault<string, 'tail'>;
|
|
656
762
|
}
|
|
657
763
|
|
|
658
764
|
type ComponentType = HostComponent<NativeProps>;
|
|
@@ -33,18 +33,23 @@ export type {
|
|
|
33
33
|
OnEndMentionEvent,
|
|
34
34
|
} from './EnrichedMarkdownTextInputNativeComponent';
|
|
35
35
|
import type {
|
|
36
|
+
GestureResponderEvent,
|
|
36
37
|
HostInstance,
|
|
37
38
|
NativeSyntheticEvent,
|
|
39
|
+
TextInputProps,
|
|
38
40
|
ViewProps,
|
|
39
41
|
ViewStyle,
|
|
40
42
|
TextStyle,
|
|
41
43
|
ColorValue,
|
|
42
44
|
} from 'react-native';
|
|
45
|
+
import { Platform } from 'react-native';
|
|
46
|
+
import { normalizeMarkdownShortcuts } from './normalizeMarkdownShortcuts';
|
|
43
47
|
import type { OnPasteEvent } from './types/events';
|
|
44
48
|
import { normalizeMarkdownTextInputStyle } from './normalizeMarkdownTextInputStyle';
|
|
45
49
|
import { normalizeMenuItem } from './normalizeMenuItem';
|
|
46
50
|
import { toNativeRegexConfig } from './utils/regexParser';
|
|
47
51
|
import { TextInputState } from './utils/textInputState';
|
|
52
|
+
import { usePressability } from './utils/usePressability';
|
|
48
53
|
import type { RefObject } from 'react';
|
|
49
54
|
|
|
50
55
|
type NativeRef = HostInstance;
|
|
@@ -265,10 +270,27 @@ export interface FormatMenuConfig {
|
|
|
265
270
|
link?: MenuItem;
|
|
266
271
|
}
|
|
267
272
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
273
|
+
/**
|
|
274
|
+
* Which typed markdown block prefixes convert into blocks. An omitted key is
|
|
275
|
+
* off, so `{ heading: true }` enables headings and nothing else.
|
|
276
|
+
*/
|
|
277
|
+
export interface MarkdownShortcutsConfig {
|
|
278
|
+
/** `#`–`######` + space. @default false */
|
|
279
|
+
heading?: boolean;
|
|
280
|
+
/** `-`/`*`/`+` + space. @default false */
|
|
281
|
+
unorderedList?: boolean;
|
|
282
|
+
/** `1.` or `1)` + space. @default false */
|
|
283
|
+
orderedList?: boolean;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface EnrichedMarkdownTextInputProps
|
|
287
|
+
extends
|
|
288
|
+
Omit<ViewProps, 'style' | 'children'>,
|
|
289
|
+
// Same press props as React Native TextInput; `hitSlop` comes from ViewProps.
|
|
290
|
+
Pick<
|
|
291
|
+
TextInputProps,
|
|
292
|
+
'onPress' | 'onPressIn' | 'onPressOut' | 'rejectResponderTermination'
|
|
293
|
+
> {
|
|
272
294
|
ref?: RefObject<EnrichedMarkdownTextInputInstance | null>;
|
|
273
295
|
defaultValue?: string;
|
|
274
296
|
placeholder?: string;
|
|
@@ -277,6 +299,18 @@ export interface EnrichedMarkdownTextInputProps extends Omit<
|
|
|
277
299
|
autoFocus?: boolean;
|
|
278
300
|
scrollEnabled?: boolean;
|
|
279
301
|
blockSyntax?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Converts markdown block prefixes typed at the start of a paragraph into
|
|
304
|
+
* blocks, the way Notion, Bear and Obsidian do: `#`–`######` + space becomes
|
|
305
|
+
* a heading, `-`/`*`/`+` + space a bullet item, `1.` (or `1)`) + space a
|
|
306
|
+
* numbered item. The prefix and its space are removed from the text.
|
|
307
|
+
* `true` enables all three; pass a {@link MarkdownShortcutsConfig} to enable
|
|
308
|
+
* a subset. Off by default so apps that treat `#` or `-` as literal text
|
|
309
|
+
* (tags, dashes) see no change. Ignored (always off) when `blockSyntax` is
|
|
310
|
+
* `false`.
|
|
311
|
+
* @default false
|
|
312
|
+
*/
|
|
313
|
+
markdownShortcuts?: boolean | MarkdownShortcutsConfig;
|
|
280
314
|
autoCapitalize?: string;
|
|
281
315
|
/**
|
|
282
316
|
* Report pastes through `onPaste` instead of inserting them. Only takes
|
|
@@ -374,6 +408,7 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
374
408
|
autoFocus = false,
|
|
375
409
|
scrollEnabled = true,
|
|
376
410
|
blockSyntax = true,
|
|
411
|
+
markdownShortcuts,
|
|
377
412
|
autoCapitalize = 'sentences',
|
|
378
413
|
interceptPaste = false,
|
|
379
414
|
multiline = true,
|
|
@@ -394,6 +429,11 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
394
429
|
onEndMention,
|
|
395
430
|
onFocus,
|
|
396
431
|
onBlur,
|
|
432
|
+
onPress,
|
|
433
|
+
onPressIn,
|
|
434
|
+
onPressOut,
|
|
435
|
+
hitSlop,
|
|
436
|
+
rejectResponderTermination = true,
|
|
397
437
|
contextMenuItems,
|
|
398
438
|
selectionMenuConfig,
|
|
399
439
|
formatMenuConfig,
|
|
@@ -522,6 +562,13 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
522
562
|
};
|
|
523
563
|
}, [formatMenuConfig]);
|
|
524
564
|
|
|
565
|
+
// Fork: shortcuts consume the typed prefix, which breaks the byte-for-byte
|
|
566
|
+
// round-trip `blockSyntax={false}` promises — force them off in that mode.
|
|
567
|
+
const normalizedMarkdownShortcuts = useMemo(
|
|
568
|
+
() => normalizeMarkdownShortcuts(blockSyntax ? markdownShortcuts : false),
|
|
569
|
+
[blockSyntax, markdownShortcuts]
|
|
570
|
+
);
|
|
571
|
+
|
|
525
572
|
const linkRegex = useMemo(
|
|
526
573
|
() => toNativeRegexConfig(_linkRegex),
|
|
527
574
|
[_linkRegex]
|
|
@@ -647,6 +694,51 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
647
694
|
onBlur?.();
|
|
648
695
|
}, [onBlur]);
|
|
649
696
|
|
|
697
|
+
/**
|
|
698
|
+
* React Native TextInput attaches usePressability to the native host so taps
|
|
699
|
+
* claim the JS touch responder and ancestor Pressable handlers do not also
|
|
700
|
+
* run.
|
|
701
|
+
* https://github.com/react/react-native/blob/v0.86.2/packages/react-native/Libraries/Components/TextInput/TextInput.js#L582-L616
|
|
702
|
+
*/
|
|
703
|
+
const pressabilityConfig = useMemo(
|
|
704
|
+
() => ({
|
|
705
|
+
cancelable:
|
|
706
|
+
Platform.OS === 'ios' ? !rejectResponderTermination : undefined,
|
|
707
|
+
hitSlop,
|
|
708
|
+
onPress: (event: GestureResponderEvent) => {
|
|
709
|
+
onPress?.(event);
|
|
710
|
+
if (editable !== false) {
|
|
711
|
+
// Same call TextInput's host focus() makes. A tap on the text view
|
|
712
|
+
// focuses it natively, which makes this a no-op; it matters when the
|
|
713
|
+
// press lands outside the native view, e.g. in the hitSlop area.
|
|
714
|
+
TextInputState.focusTextInput(nativeRef.current);
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
onPressIn,
|
|
718
|
+
onPressOut,
|
|
719
|
+
}),
|
|
720
|
+
[
|
|
721
|
+
editable,
|
|
722
|
+
hitSlop,
|
|
723
|
+
onPress,
|
|
724
|
+
onPressIn,
|
|
725
|
+
onPressOut,
|
|
726
|
+
rejectResponderTermination,
|
|
727
|
+
]
|
|
728
|
+
);
|
|
729
|
+
|
|
730
|
+
// TextInput handles onBlur and onFocus events
|
|
731
|
+
// so omitting onBlur and onFocus pressability handlers here.
|
|
732
|
+
//
|
|
733
|
+
// Same logic as https://github.com/react/react-native/blob/v0.86.2/packages/react-native/Libraries/Components/TextInput/TextInput.js#L629
|
|
734
|
+
const {
|
|
735
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
736
|
+
onBlur: _onBlur,
|
|
737
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
738
|
+
onFocus: _onFocus,
|
|
739
|
+
...pressabilityHandlers
|
|
740
|
+
} = usePressability(pressabilityConfig) ?? {};
|
|
741
|
+
|
|
650
742
|
const handleRequestMarkdownResult = useCallback(
|
|
651
743
|
(e: NativeSyntheticEvent<OnRequestMarkdownResultEvent>) => {
|
|
652
744
|
const { requestId, markdown } = e.nativeEvent;
|
|
@@ -771,6 +863,7 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
771
863
|
autoFocus={autoFocus}
|
|
772
864
|
scrollEnabled={scrollEnabled}
|
|
773
865
|
blockSyntax={blockSyntax}
|
|
866
|
+
markdownShortcuts={normalizedMarkdownShortcuts}
|
|
774
867
|
autoCapitalize={autoCapitalize}
|
|
775
868
|
interceptPaste={interceptPaste === true && onPaste != null}
|
|
776
869
|
multiline={multiline}
|
|
@@ -810,7 +903,11 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
810
903
|
onStartMention={handleStartMention as NativeProps['onStartMention']}
|
|
811
904
|
onChangeMention={handleChangeMention as NativeProps['onChangeMention']}
|
|
812
905
|
onEndMention={handleEndMention as NativeProps['onEndMention']}
|
|
906
|
+
// Explicitly pass through hitSlop because the native view subclasses
|
|
907
|
+
// RCTViewComponentView and makes use of hitSlop too
|
|
908
|
+
hitSlop={hitSlop}
|
|
813
909
|
{...rest}
|
|
910
|
+
{...pressabilityHandlers}
|
|
814
911
|
/>
|
|
815
912
|
);
|
|
816
913
|
};
|
|
@@ -205,6 +205,12 @@ export interface FormatMenuConfigInternal {
|
|
|
205
205
|
linkLabel: string;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
export interface MarkdownShortcutsConfigInternal {
|
|
209
|
+
heading: boolean;
|
|
210
|
+
unorderedList: boolean;
|
|
211
|
+
orderedList: boolean;
|
|
212
|
+
}
|
|
213
|
+
|
|
208
214
|
export interface OnContextMenuItemPressEvent {
|
|
209
215
|
itemText: string;
|
|
210
216
|
selectedText: string;
|
|
@@ -262,6 +268,12 @@ export interface NativeProps extends ViewProps {
|
|
|
262
268
|
* @default true
|
|
263
269
|
*/
|
|
264
270
|
blockSyntax?: boolean;
|
|
271
|
+
/**
|
|
272
|
+
* Which markdown block prefixes typed at a paragraph start convert into the
|
|
273
|
+
* matching block. Always complete — the JS side normalizes the public
|
|
274
|
+
* `boolean | MarkdownShortcutsConfig` form before it gets here.
|
|
275
|
+
*/
|
|
276
|
+
markdownShortcuts: Readonly<MarkdownShortcutsConfigInternal>;
|
|
265
277
|
/**
|
|
266
278
|
* Auto-capitalization behavior.
|
|
267
279
|
*/
|
|
@@ -27,6 +27,19 @@ interface HeadingStyleInternal extends BaseBlockStyleInternal {
|
|
|
27
27
|
textAlign: string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
interface AdmonitionColorsInternal {
|
|
31
|
+
color: ColorValue;
|
|
32
|
+
backgroundColor: ColorValue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface AdmonitionsStyleInternal {
|
|
36
|
+
note: AdmonitionColorsInternal;
|
|
37
|
+
tip: AdmonitionColorsInternal;
|
|
38
|
+
important: AdmonitionColorsInternal;
|
|
39
|
+
warning: AdmonitionColorsInternal;
|
|
40
|
+
caution: AdmonitionColorsInternal;
|
|
41
|
+
}
|
|
42
|
+
|
|
30
43
|
interface BlockquoteStyleInternal extends BaseBlockStyleInternal {
|
|
31
44
|
borderColor: ColorValue;
|
|
32
45
|
borderWidth: CodegenTypes.Float;
|
|
@@ -34,6 +47,7 @@ interface BlockquoteStyleInternal extends BaseBlockStyleInternal {
|
|
|
34
47
|
backgroundColor: ColorValue;
|
|
35
48
|
borderRadius: CodegenTypes.Float;
|
|
36
49
|
padding: CodegenTypes.Float;
|
|
50
|
+
admonitions: AdmonitionsStyleInternal;
|
|
37
51
|
}
|
|
38
52
|
|
|
39
53
|
interface ListStyleInternal extends BaseBlockStyleInternal {
|
|
@@ -96,6 +110,7 @@ interface LinkVariantEntryInternal {
|
|
|
96
110
|
paddingVertical: CodegenTypes.Float;
|
|
97
111
|
borderColor: ColorValue;
|
|
98
112
|
borderWidth: CodegenTypes.Float;
|
|
113
|
+
fontFamily: string;
|
|
99
114
|
}
|
|
100
115
|
|
|
101
116
|
interface StrongStyleInternal {
|
|
@@ -137,6 +152,14 @@ interface ImageStyleInternal {
|
|
|
137
152
|
marginBottom: CodegenTypes.Float;
|
|
138
153
|
}
|
|
139
154
|
|
|
155
|
+
interface VideoStyleInternal {
|
|
156
|
+
marginTop: CodegenTypes.Float;
|
|
157
|
+
marginBottom: CodegenTypes.Float;
|
|
158
|
+
borderRadius: CodegenTypes.Float;
|
|
159
|
+
aspectRatio: CodegenTypes.Float;
|
|
160
|
+
backgroundColor: ColorValue;
|
|
161
|
+
}
|
|
162
|
+
|
|
140
163
|
interface InlineImageStyleInternal {
|
|
141
164
|
size: CodegenTypes.Float;
|
|
142
165
|
}
|
|
@@ -241,6 +264,7 @@ export interface MarkdownStyleInternal {
|
|
|
241
264
|
underline: UnderlineStyleInternal;
|
|
242
265
|
code: CodeStyleInternal;
|
|
243
266
|
image: ImageStyleInternal;
|
|
267
|
+
video: VideoStyleInternal;
|
|
244
268
|
inlineImage: InlineImageStyleInternal;
|
|
245
269
|
thematicBreak: ThematicBreakStyleInternal;
|
|
246
270
|
table: TableStyleInternal;
|
|
@@ -281,9 +305,9 @@ export interface LinkLayoutEvent {
|
|
|
281
305
|
}
|
|
282
306
|
|
|
283
307
|
/**
|
|
284
|
-
* Current text selection, or a long-pressed table / math / code
|
|
285
|
-
* `contextMenuHidden` is on. `active: false` means the selection
|
|
286
|
-
* (every other field is then empty / zero). Rects are in dp / pt, relative to
|
|
308
|
+
* Current text selection, or a long-pressed table / math / code / blockquote
|
|
309
|
+
* block while `contextMenuHidden` is on. `active: false` means the selection
|
|
310
|
+
* was cleared (every other field is then empty / zero). Rects are in dp / pt, relative to
|
|
287
311
|
* the native view's origin; rect objects are written inline because codegen
|
|
288
312
|
* only accepts inline object literals in event payloads.
|
|
289
313
|
*/
|
|
@@ -314,6 +338,11 @@ export interface SelectionChangeEvent {
|
|
|
314
338
|
adjusting: boolean;
|
|
315
339
|
}
|
|
316
340
|
|
|
341
|
+
export interface ImagePressEvent {
|
|
342
|
+
url: string;
|
|
343
|
+
altText: string;
|
|
344
|
+
}
|
|
345
|
+
|
|
317
346
|
export interface TaskListItemPressEvent {
|
|
318
347
|
index: CodegenTypes.Int32;
|
|
319
348
|
checked: boolean;
|
|
@@ -326,13 +355,24 @@ export interface CopyPressEvent {
|
|
|
326
355
|
}
|
|
327
356
|
|
|
328
357
|
export interface CopyRequestEvent {
|
|
329
|
-
// 'selection' | 'math' | 'table' | 'code'
|
|
358
|
+
// 'selection' | 'math' | 'table' | 'code' | 'blockquote'
|
|
330
359
|
source: string;
|
|
331
360
|
markdown: string;
|
|
332
361
|
text: string;
|
|
333
362
|
whole: boolean;
|
|
334
363
|
}
|
|
335
364
|
|
|
365
|
+
export interface LatexErrorEvent {
|
|
366
|
+
source: string;
|
|
367
|
+
message: string;
|
|
368
|
+
displayMode: boolean;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export interface CodeBlockPressEvent {
|
|
372
|
+
code: string;
|
|
373
|
+
language: string;
|
|
374
|
+
}
|
|
375
|
+
|
|
336
376
|
export interface ContextMenuItemConfig {
|
|
337
377
|
text: string;
|
|
338
378
|
icon?: string;
|
|
@@ -439,6 +479,17 @@ export interface Md4cFlagsInternal {
|
|
|
439
479
|
* @default false
|
|
440
480
|
*/
|
|
441
481
|
hardSoftBreaks: boolean;
|
|
482
|
+
/**
|
|
483
|
+
* Preserve runs of consecutive blank lines as extra empty lines.
|
|
484
|
+
* @default false
|
|
485
|
+
*/
|
|
486
|
+
preserveBlankLines: boolean;
|
|
487
|
+
/**
|
|
488
|
+
* Enable GitHub-style admonitions/alerts extension.
|
|
489
|
+
* Forced off for `flavor="commonmark"`.
|
|
490
|
+
* @default true
|
|
491
|
+
*/
|
|
492
|
+
admonitions: boolean;
|
|
442
493
|
}
|
|
443
494
|
|
|
444
495
|
interface StreamingConfigInternal {
|
|
@@ -493,6 +544,22 @@ export interface NativeProps extends ViewProps {
|
|
|
493
544
|
* deduplicated, and `active: false` once the selection is gone.
|
|
494
545
|
*/
|
|
495
546
|
onSelectionChange?: CodegenTypes.DirectEventHandler<SelectionChangeEvent>;
|
|
547
|
+
/**
|
|
548
|
+
* Callback fired when a rendered image is tapped.
|
|
549
|
+
* Receives the image URL and its alt text (empty string when the image has
|
|
550
|
+
* no alt text). Images that are also links keep link behavior and emit
|
|
551
|
+
* `onLinkPress` instead, so a single tap never fires both.
|
|
552
|
+
*/
|
|
553
|
+
onImagePress?: CodegenTypes.BubblingEventHandler<ImagePressEvent>;
|
|
554
|
+
/**
|
|
555
|
+
* Gates native image tap handling. Set automatically to `true` by the JS
|
|
556
|
+
* wrapper when `onImagePress` is provided. When `false` (default), images are
|
|
557
|
+
* inert: taps fall through to text selection and the iOS Copy/Save menu
|
|
558
|
+
* exactly as before, and no image span becomes interactive on Android.
|
|
559
|
+
*
|
|
560
|
+
* @default false
|
|
561
|
+
*/
|
|
562
|
+
enableImagePress?: CodegenTypes.WithDefault<boolean, false>;
|
|
496
563
|
/**
|
|
497
564
|
* Callback fired when a task list checkbox is tapped.
|
|
498
565
|
* Receives the 0-based task index, current checked state, and the item's plain text.
|
|
@@ -513,6 +580,30 @@ export interface NativeProps extends ViewProps {
|
|
|
513
580
|
* action. Receives the copied code and its language.
|
|
514
581
|
*/
|
|
515
582
|
onCopyPress?: CodegenTypes.BubblingEventHandler<CopyPressEvent>;
|
|
583
|
+
/** Fired when a fenced code block is tapped. Receives its code and language. */
|
|
584
|
+
onCodeBlockPress?: CodegenTypes.BubblingEventHandler<CodeBlockPressEvent>;
|
|
585
|
+
/**
|
|
586
|
+
* Gates native code block tap handling; set to `true` by the JS wrapper when
|
|
587
|
+
* `onCodeBlockPress` is provided.
|
|
588
|
+
* @default false
|
|
589
|
+
*/
|
|
590
|
+
enableCodeBlockPress?: CodegenTypes.WithDefault<boolean, false>;
|
|
591
|
+
/**
|
|
592
|
+
* Callback fired when a math expression cannot be parsed or rendered by the
|
|
593
|
+
* LaTeX engine. Receives the raw LaTeX `source` of the failing inline span or
|
|
594
|
+
* block (no delimiters), the engine's error `message` (empty when none), and
|
|
595
|
+
* `displayMode` (false = inline `$...$`, true = block `$$...$$`). The whole
|
|
596
|
+
* expression is the unit of failure; the engine does not report a single
|
|
597
|
+
* offending command.
|
|
598
|
+
*/
|
|
599
|
+
onLatexError?: CodegenTypes.BubblingEventHandler<LatexErrorEvent>;
|
|
600
|
+
/**
|
|
601
|
+
* Controls the long-press copy menu on code blocks, tables, block math, and blockquotes/admonitions.
|
|
602
|
+
* `contextMenuHidden` takes precedence: when it is true no block menu is
|
|
603
|
+
* shown regardless of this flag.
|
|
604
|
+
* @default true
|
|
605
|
+
*/
|
|
606
|
+
enableBlockContextMenu?: CodegenTypes.WithDefault<boolean, true>;
|
|
516
607
|
/**
|
|
517
608
|
* Fired instead of writing the clipboard when the Copy item of the text
|
|
518
609
|
* selection menu or a table / math / code block menu is pressed while
|
|
@@ -570,6 +661,8 @@ export interface NativeProps extends ViewProps {
|
|
|
570
661
|
* Controls how the markdown parser interprets certain syntax.
|
|
571
662
|
*/
|
|
572
663
|
md4cFlags: Md4cFlagsInternal;
|
|
664
|
+
/** Enables the GFM table, strikethrough, and task-list extensions. */
|
|
665
|
+
isGFM?: CodegenTypes.WithDefault<boolean, false>;
|
|
573
666
|
/**
|
|
574
667
|
* Specifies whether fonts should scale to respect Text Size accessibility settings.
|
|
575
668
|
* When false, text will not scale with the user's accessibility settings.
|
|
@@ -653,6 +746,24 @@ export interface NativeProps extends ViewProps {
|
|
|
653
746
|
* @platform ios
|
|
654
747
|
*/
|
|
655
748
|
writingDirection?: CodegenTypes.WithDefault<string, 'first-strong'>;
|
|
749
|
+
/**
|
|
750
|
+
* Maximum number of lines to display before the text is truncated. 0 (the
|
|
751
|
+
* default) means unlimited. Matches React Native Text's `numberOfLines`.
|
|
752
|
+
* Only applies to CommonMark; ignored when the flavor is 'github'.
|
|
753
|
+
* Android: while clamped the view is not selectable and links are not tappable
|
|
754
|
+
* (DynamicLayout has no maxLines support, so selection/links would drop the
|
|
755
|
+
* ellipsis); both are restored once the clamp is removed. iOS is unaffected.
|
|
756
|
+
* @default 0
|
|
757
|
+
*/
|
|
758
|
+
numberOfLines?: CodegenTypes.WithDefault<CodegenTypes.Int32, 0>;
|
|
759
|
+
/**
|
|
760
|
+
* Where to place the ellipsis when text is truncated by `numberOfLines`:
|
|
761
|
+
* 'head' | 'middle' | 'tail' | 'clip' ('clip' cuts with no ellipsis). Only
|
|
762
|
+
* takes effect when `numberOfLines` is set. Matches React Native Text's
|
|
763
|
+
* `ellipsizeMode`. Ignored when the flavor is 'github'.
|
|
764
|
+
* @default 'tail'
|
|
765
|
+
*/
|
|
766
|
+
ellipsizeMode?: CodegenTypes.WithDefault<string, 'tail'>;
|
|
656
767
|
}
|
|
657
768
|
|
|
658
769
|
type ComponentType = HostComponent<NativeProps>;
|