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
|
@@ -23,6 +23,18 @@ NSLineBreakStrategy ENRMResolveLineBreakStrategy(NSString *strategy)
|
|
|
23
23
|
return NSLineBreakStrategyNone;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
NSLineBreakMode ENRMResolveEllipsizeLineBreakMode(NSString *mode)
|
|
27
|
+
{
|
|
28
|
+
if ([mode isEqualToString:@"head"]) {
|
|
29
|
+
return NSLineBreakByTruncatingHead;
|
|
30
|
+
} else if ([mode isEqualToString:@"middle"]) {
|
|
31
|
+
return NSLineBreakByTruncatingMiddle;
|
|
32
|
+
} else if ([mode isEqualToString:@"clip"]) {
|
|
33
|
+
return NSLineBreakByClipping;
|
|
34
|
+
}
|
|
35
|
+
return NSLineBreakByTruncatingTail;
|
|
36
|
+
}
|
|
37
|
+
|
|
26
38
|
__attribute__((constructor)) static void initParagraphStyleUtils(void)
|
|
27
39
|
{
|
|
28
40
|
kNewlineAttributedString = [[NSAttributedString alloc] initWithString:@"\n"];
|
|
@@ -150,6 +162,11 @@ void ENRMApplyWritingDirectionToParagraphStyles(NSMutableAttributedString *outpu
|
|
|
150
162
|
if (!style) {
|
|
151
163
|
return;
|
|
152
164
|
}
|
|
165
|
+
// Skip runs already in the target direction (issue #739),
|
|
166
|
+
// mirroring ENRMApplyFirstStrongParagraphDirections.
|
|
167
|
+
if (style.baseWritingDirection == writingDirection) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
153
170
|
NSNumber *isCodeBlock = [output attribute:CodeBlockAttributeName
|
|
154
171
|
atIndex:range.location
|
|
155
172
|
effectiveRange:nil];
|
|
@@ -247,6 +264,26 @@ void applyBlockSpacingAfter(NSMutableAttributedString *output, CGFloat marginBot
|
|
|
247
264
|
[output addAttribute:NSParagraphStyleAttributeName value:spacerStyle range:NSMakeRange(spacerLocation, 1)];
|
|
248
265
|
}
|
|
249
266
|
|
|
267
|
+
// UIKit's own key for the pre-substitution font. Not exported by any SDK header, so it is spelled out
|
|
268
|
+
// here; it is the same string UIKit writes into a UITextView's storage when it substitutes a font.
|
|
269
|
+
static NSString *const ENRMOriginalFontAttributeName = @"NSOriginalFont";
|
|
270
|
+
|
|
271
|
+
void ENRMPinLineMetricsToStyledFonts(NSMutableAttributedString *output, NSRange range)
|
|
272
|
+
{
|
|
273
|
+
if (range.length == 0 || NSMaxRange(range) > output.length) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
[output enumerateAttribute:NSFontAttributeName
|
|
278
|
+
inRange:range
|
|
279
|
+
options:0
|
|
280
|
+
usingBlock:^(UIFont *font, NSRange fontRange, __unused BOOL *stop) {
|
|
281
|
+
if (font) {
|
|
282
|
+
[output addAttribute:ENRMOriginalFontAttributeName value:font range:fontRange];
|
|
283
|
+
}
|
|
284
|
+
}];
|
|
285
|
+
}
|
|
286
|
+
|
|
250
287
|
BOOL ENRMRangeContainsBlockImage(NSAttributedString *output, NSRange range)
|
|
251
288
|
{
|
|
252
289
|
__block BOOL found = NO;
|
|
@@ -262,6 +299,13 @@ BOOL ENRMRangeContainsBlockImage(NSAttributedString *output, NSRange range)
|
|
|
262
299
|
return found;
|
|
263
300
|
}
|
|
264
301
|
|
|
302
|
+
// Fork decision (merge v1.1.1, D7 option b): CLAMP text-only lines, do not take upstream's floor (#832).
|
|
303
|
+
// Text-only lines get minimumLineHeight = maximumLineHeight = lineHeight, so a font whose natural line
|
|
304
|
+
// height exceeds the configured lineHeight (e.g. Baloo 2 at lineHeight = 1.5 x fontSize) is compressed
|
|
305
|
+
// to exactly lineHeight, keeping line-capped containers stable. Lines carrying inline math or a block
|
|
306
|
+
// image are carved out (maximumLineHeight = 0, i.e. floor only) because TextKit would otherwise cut the
|
|
307
|
+
// line fragment below the attachment's drawn height and the overflow paints over neighbouring lines.
|
|
308
|
+
// Trade-off vs upstream: a very tall inline code run on a text-only line is still clamped.
|
|
265
309
|
void applyLineHeight(NSMutableAttributedString *output, NSRange range, CGFloat lineHeight)
|
|
266
310
|
{
|
|
267
311
|
if (lineHeight <= 0) {
|
|
@@ -292,17 +336,18 @@ void applyLineHeight(NSMutableAttributedString *output, NSRange range, CGFloat l
|
|
|
292
336
|
[output addAttribute:NSParagraphStyleAttributeName value:style range:range];
|
|
293
337
|
}
|
|
294
338
|
|
|
295
|
-
//
|
|
296
|
-
//
|
|
297
|
-
//
|
|
298
|
-
//
|
|
339
|
+
// Centers text within its line height by offsetting the baseline by half the leading, matching how
|
|
340
|
+
// Android's LineHeightSpan splits the extra leading evenly above and below the glyphs. Called per
|
|
341
|
+
// block over its own range so blocks can keep different line heights. Ranges that already carry a
|
|
342
|
+
// baseline offset are left untouched, keeping nesting (e.g. a blockquote wrapping list items) idempotent.
|
|
299
343
|
void applyBaselineOffset(NSMutableAttributedString *output, NSRange range)
|
|
300
344
|
{
|
|
301
345
|
if (range.length == 0) {
|
|
302
346
|
return;
|
|
303
347
|
}
|
|
304
348
|
|
|
305
|
-
//
|
|
349
|
+
// applyLineHeight sets minimumLineHeight on every line: clamped text lines have max == min, and
|
|
350
|
+
// math / block-image lines leave maximumLineHeight at 0, so the target is the minimum line height.
|
|
306
351
|
__block CGFloat targetLineHeight = 0;
|
|
307
352
|
[output enumerateAttribute:NSParagraphStyleAttributeName
|
|
308
353
|
inRange:range
|
|
@@ -311,8 +356,7 @@ void applyBaselineOffset(NSMutableAttributedString *output, NSRange range)
|
|
|
311
356
|
if (!paragraphStyle) {
|
|
312
357
|
return;
|
|
313
358
|
}
|
|
314
|
-
|
|
315
|
-
targetLineHeight = MAX(clamp, targetLineHeight);
|
|
359
|
+
targetLineHeight = MAX(paragraphStyle.minimumLineHeight, targetLineHeight);
|
|
316
360
|
}];
|
|
317
361
|
|
|
318
362
|
if (targetLineHeight <= 0) {
|
|
@@ -491,6 +491,36 @@ BOOL applyMarkdownStyleToConfig(StyleConfig *config, const MarkdownStyle &newSty
|
|
|
491
491
|
changed = YES;
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
+
const auto &newAdm = newStyle.blockquote.admonitions;
|
|
495
|
+
const auto &oldAdm = oldStyle.blockquote.admonitions;
|
|
496
|
+
BOOL admonitionsChanged =
|
|
497
|
+
newAdm.note.color != oldAdm.note.color || newAdm.note.backgroundColor != oldAdm.note.backgroundColor ||
|
|
498
|
+
newAdm.tip.color != oldAdm.tip.color || newAdm.tip.backgroundColor != oldAdm.tip.backgroundColor ||
|
|
499
|
+
newAdm.important.color != oldAdm.important.color ||
|
|
500
|
+
newAdm.important.backgroundColor != oldAdm.important.backgroundColor ||
|
|
501
|
+
newAdm.warning.color != oldAdm.warning.color ||
|
|
502
|
+
newAdm.warning.backgroundColor != oldAdm.warning.backgroundColor ||
|
|
503
|
+
newAdm.caution.color != oldAdm.caution.color || newAdm.caution.backgroundColor != oldAdm.caution.backgroundColor;
|
|
504
|
+
if (admonitionsChanged) {
|
|
505
|
+
RCTUIColor *clear = [RCTUIColor clearColor];
|
|
506
|
+
NSDictionary<NSString *, RCTUIColor *> *admonitionColors = @{
|
|
507
|
+
@"note" : RCTUIColorFromSharedColor(newAdm.note.color) ?: clear,
|
|
508
|
+
@"tip" : RCTUIColorFromSharedColor(newAdm.tip.color) ?: clear,
|
|
509
|
+
@"important" : RCTUIColorFromSharedColor(newAdm.important.color) ?: clear,
|
|
510
|
+
@"warning" : RCTUIColorFromSharedColor(newAdm.warning.color) ?: clear,
|
|
511
|
+
@"caution" : RCTUIColorFromSharedColor(newAdm.caution.color) ?: clear,
|
|
512
|
+
};
|
|
513
|
+
NSDictionary<NSString *, RCTUIColor *> *admonitionBackgroundColors = @{
|
|
514
|
+
@"note" : RCTUIColorFromSharedColor(newAdm.note.backgroundColor) ?: clear,
|
|
515
|
+
@"tip" : RCTUIColorFromSharedColor(newAdm.tip.backgroundColor) ?: clear,
|
|
516
|
+
@"important" : RCTUIColorFromSharedColor(newAdm.important.backgroundColor) ?: clear,
|
|
517
|
+
@"warning" : RCTUIColorFromSharedColor(newAdm.warning.backgroundColor) ?: clear,
|
|
518
|
+
@"caution" : RCTUIColorFromSharedColor(newAdm.caution.backgroundColor) ?: clear,
|
|
519
|
+
};
|
|
520
|
+
[config setAdmonitionColors:admonitionColors backgroundColors:admonitionBackgroundColors];
|
|
521
|
+
changed = YES;
|
|
522
|
+
}
|
|
523
|
+
|
|
494
524
|
// ── Link ───────────────────────────────────────────────────────────────────
|
|
495
525
|
|
|
496
526
|
if (newStyle.link.fontFamily != oldStyle.link.fontFamily) {
|
|
@@ -560,7 +590,8 @@ BOOL applyMarkdownStyleToConfig(StyleConfig *config, const MarkdownStyle &newSty
|
|
|
560
590
|
newVariant.borderRadius != oldVariant.borderRadius ||
|
|
561
591
|
newVariant.paddingHorizontal != oldVariant.paddingHorizontal ||
|
|
562
592
|
newVariant.paddingVertical != oldVariant.paddingVertical ||
|
|
563
|
-
newVariant.borderColor != oldVariant.borderColor || newVariant.borderWidth != oldVariant.borderWidth
|
|
593
|
+
newVariant.borderColor != oldVariant.borderColor || newVariant.borderWidth != oldVariant.borderWidth ||
|
|
594
|
+
newVariant.fontFamily != oldVariant.fontFamily) {
|
|
564
595
|
linkVariantsChanged = YES;
|
|
565
596
|
break;
|
|
566
597
|
}
|
|
@@ -573,6 +604,7 @@ BOOL applyMarkdownStyleToConfig(StyleConfig *config, const MarkdownStyle &newSty
|
|
|
573
604
|
variant.pattern = [[NSString alloc] initWithUTF8String:entry.pattern.c_str()];
|
|
574
605
|
variant.color = RCTUIColorFromSharedColor(entry.color);
|
|
575
606
|
variant.underline = entry.underline;
|
|
607
|
+
variant.fontFamily = [[NSString alloc] initWithUTF8String:entry.fontFamily.c_str()];
|
|
576
608
|
RCTUIColor *backgroundColor = RCTUIColorFromSharedColor(entry.backgroundColor);
|
|
577
609
|
variant.backgroundColor = CGColorGetAlpha(backgroundColor.CGColor) > 0 ? backgroundColor : nil;
|
|
578
610
|
variant.borderRadius = entry.borderRadius;
|
|
@@ -766,6 +798,33 @@ BOOL applyMarkdownStyleToConfig(StyleConfig *config, const MarkdownStyle &newSty
|
|
|
766
798
|
changed = YES;
|
|
767
799
|
}
|
|
768
800
|
|
|
801
|
+
// ── Video ───────────────────────────────────────────────────────────────────
|
|
802
|
+
|
|
803
|
+
if (newStyle.video.marginTop != oldStyle.video.marginTop) {
|
|
804
|
+
[config setVideoMarginTop:newStyle.video.marginTop];
|
|
805
|
+
changed = YES;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
if (newStyle.video.marginBottom != oldStyle.video.marginBottom) {
|
|
809
|
+
[config setVideoMarginBottom:newStyle.video.marginBottom];
|
|
810
|
+
changed = YES;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
if (newStyle.video.borderRadius != oldStyle.video.borderRadius) {
|
|
814
|
+
[config setVideoBorderRadius:newStyle.video.borderRadius];
|
|
815
|
+
changed = YES;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
if (newStyle.video.aspectRatio != oldStyle.video.aspectRatio) {
|
|
819
|
+
[config setVideoAspectRatio:newStyle.video.aspectRatio];
|
|
820
|
+
changed = YES;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
if (newStyle.video.backgroundColor != oldStyle.video.backgroundColor) {
|
|
824
|
+
[config setVideoBackgroundColor:RCTUIColorFromSharedColor(newStyle.video.backgroundColor)];
|
|
825
|
+
changed = YES;
|
|
826
|
+
}
|
|
827
|
+
|
|
769
828
|
// ── Inline Image ───────────────────────────────────────────────────────────
|
|
770
829
|
|
|
771
830
|
if (newStyle.inlineImage.size != oldStyle.inlineImage.size) {
|
|
@@ -47,6 +47,63 @@
|
|
|
47
47
|
[markerDrawer drawMarkersForGlyphRange:glyphsToShow layoutManager:self textContainer:textContainer atPoint:origin];
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
#pragma mark - Decoration baseline correction
|
|
51
|
+
|
|
52
|
+
/// Returns the NSBaselineOffsetAttributeName value for the first character in
|
|
53
|
+
/// the given glyph range, or 0 when the attribute is absent.
|
|
54
|
+
///
|
|
55
|
+
/// applyBaselineOffset (ParagraphStyleUtils) shifts glyphs upward so text is
|
|
56
|
+
/// vertically centered within a line height larger than the font's natural
|
|
57
|
+
/// height. TextKit 1 does not account for this shift when drawing underline
|
|
58
|
+
/// and strikethrough decorations — it draws them at the original, unshifted
|
|
59
|
+
/// baseline. Reading the attribute here lets the draw overrides below
|
|
60
|
+
/// compensate by the same amount.
|
|
61
|
+
- (CGFloat)baselineShiftForGlyphRange:(NSRange)glyphRange
|
|
62
|
+
{
|
|
63
|
+
NSTextStorage *storage = self.textStorage;
|
|
64
|
+
if (!storage || storage.length == 0)
|
|
65
|
+
return 0;
|
|
66
|
+
|
|
67
|
+
NSUInteger charIndex = [self characterIndexForGlyphAtIndex:glyphRange.location];
|
|
68
|
+
if (charIndex >= storage.length)
|
|
69
|
+
return 0;
|
|
70
|
+
|
|
71
|
+
NSNumber *offset = [storage attribute:NSBaselineOffsetAttributeName atIndex:charIndex effectiveRange:NULL];
|
|
72
|
+
return offset ? offset.doubleValue : 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
- (void)drawUnderlineForGlyphRange:(NSRange)glyphRange
|
|
76
|
+
underlineType:(NSUnderlineStyle)underlineVal
|
|
77
|
+
baselineOffset:(CGFloat)baselineOffset
|
|
78
|
+
lineFragmentRect:(CGRect)lineRect
|
|
79
|
+
lineFragmentGlyphRange:(NSRange)lineGlyphRange
|
|
80
|
+
containerOrigin:(CGPoint)containerOrigin
|
|
81
|
+
{
|
|
82
|
+
CGFloat shift = [self baselineShiftForGlyphRange:glyphRange];
|
|
83
|
+
[super drawUnderlineForGlyphRange:glyphRange
|
|
84
|
+
underlineType:underlineVal
|
|
85
|
+
baselineOffset:baselineOffset + shift
|
|
86
|
+
lineFragmentRect:lineRect
|
|
87
|
+
lineFragmentGlyphRange:lineGlyphRange
|
|
88
|
+
containerOrigin:containerOrigin];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
- (void)drawStrikethroughForGlyphRange:(NSRange)glyphRange
|
|
92
|
+
strikethroughType:(NSUnderlineStyle)strikethroughVal
|
|
93
|
+
baselineOffset:(CGFloat)baselineOffset
|
|
94
|
+
lineFragmentRect:(CGRect)lineRect
|
|
95
|
+
lineFragmentGlyphRange:(NSRange)lineGlyphRange
|
|
96
|
+
containerOrigin:(CGPoint)containerOrigin
|
|
97
|
+
{
|
|
98
|
+
CGFloat shift = [self baselineShiftForGlyphRange:glyphRange];
|
|
99
|
+
[super drawStrikethroughForGlyphRange:glyphRange
|
|
100
|
+
strikethroughType:strikethroughVal
|
|
101
|
+
baselineOffset:baselineOffset + shift
|
|
102
|
+
lineFragmentRect:lineRect
|
|
103
|
+
lineFragmentGlyphRange:lineGlyphRange
|
|
104
|
+
containerOrigin:containerOrigin];
|
|
105
|
+
}
|
|
106
|
+
|
|
50
107
|
#pragma mark - Safe Property Accessors
|
|
51
108
|
|
|
52
109
|
// We split these into explicit methods to avoid the 'code 257' pointer corruption
|
|
@@ -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>;
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef } from 'react';
|
|
4
4
|
import EnrichedMarkdownTextInputNativeComponent, { Commands } from './EnrichedMarkdownTextInputNativeComponent';
|
|
5
|
+
import { Platform } from 'react-native';
|
|
6
|
+
import { normalizeMarkdownShortcuts } from "./normalizeMarkdownShortcuts.js";
|
|
5
7
|
import { normalizeMarkdownTextInputStyle } from "./normalizeMarkdownTextInputStyle.js";
|
|
6
8
|
import { normalizeMenuItem } from "./normalizeMenuItem.js";
|
|
7
9
|
import { toNativeRegexConfig } from "./utils/regexParser.js";
|
|
8
10
|
import { TextInputState } from "./utils/textInputState.js";
|
|
11
|
+
import { usePressability } from "./utils/usePressability.js";
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Chip style for inline math (`$...$`) in the editor. Mirrors the read-only
|
|
@@ -32,6 +35,11 @@ function toHeadingLevel(n) {
|
|
|
32
35
|
|
|
33
36
|
/** Controls the individual items inside the Format submenu. */
|
|
34
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Which typed markdown block prefixes convert into blocks. An omitted key is
|
|
40
|
+
* off, so `{ heading: true }` enables headings and nothing else.
|
|
41
|
+
*/
|
|
42
|
+
|
|
35
43
|
function getNativeRef(ref) {
|
|
36
44
|
if (ref.current == null) {
|
|
37
45
|
throw new Error('EnrichedMarkdownTextInput: native ref is not attached. Ensure the component is mounted.');
|
|
@@ -49,6 +57,7 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
49
57
|
autoFocus = false,
|
|
50
58
|
scrollEnabled = true,
|
|
51
59
|
blockSyntax = true,
|
|
60
|
+
markdownShortcuts,
|
|
52
61
|
autoCapitalize = 'sentences',
|
|
53
62
|
interceptPaste = false,
|
|
54
63
|
multiline = true,
|
|
@@ -69,6 +78,11 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
69
78
|
onEndMention,
|
|
70
79
|
onFocus,
|
|
71
80
|
onBlur,
|
|
81
|
+
onPress,
|
|
82
|
+
onPressIn,
|
|
83
|
+
onPressOut,
|
|
84
|
+
hitSlop,
|
|
85
|
+
rejectResponderTermination = true,
|
|
72
86
|
contextMenuItems,
|
|
73
87
|
selectionMenuConfig,
|
|
74
88
|
formatMenuConfig,
|
|
@@ -164,6 +178,10 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
164
178
|
linkLabel: link.label
|
|
165
179
|
};
|
|
166
180
|
}, [formatMenuConfig]);
|
|
181
|
+
|
|
182
|
+
// Fork: shortcuts consume the typed prefix, which breaks the byte-for-byte
|
|
183
|
+
// round-trip `blockSyntax={false}` promises — force them off in that mode.
|
|
184
|
+
const normalizedMarkdownShortcuts = useMemo(() => normalizeMarkdownShortcuts(blockSyntax ? markdownShortcuts : false), [blockSyntax, markdownShortcuts]);
|
|
167
185
|
const linkRegex = useMemo(() => toNativeRegexConfig(_linkRegex), [_linkRegex]);
|
|
168
186
|
const handleLinkDetected = useCallback(e => {
|
|
169
187
|
const {
|
|
@@ -287,6 +305,40 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
287
305
|
TextInputState.blurInput(nativeRef.current);
|
|
288
306
|
onBlur?.();
|
|
289
307
|
}, [onBlur]);
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* React Native TextInput attaches usePressability to the native host so taps
|
|
311
|
+
* claim the JS touch responder and ancestor Pressable handlers do not also
|
|
312
|
+
* run.
|
|
313
|
+
* https://github.com/react/react-native/blob/v0.86.2/packages/react-native/Libraries/Components/TextInput/TextInput.js#L582-L616
|
|
314
|
+
*/
|
|
315
|
+
const pressabilityConfig = useMemo(() => ({
|
|
316
|
+
cancelable: Platform.OS === 'ios' ? !rejectResponderTermination : undefined,
|
|
317
|
+
hitSlop,
|
|
318
|
+
onPress: event => {
|
|
319
|
+
onPress?.(event);
|
|
320
|
+
if (editable !== false) {
|
|
321
|
+
// Same call TextInput's host focus() makes. A tap on the text view
|
|
322
|
+
// focuses it natively, which makes this a no-op; it matters when the
|
|
323
|
+
// press lands outside the native view, e.g. in the hitSlop area.
|
|
324
|
+
TextInputState.focusTextInput(nativeRef.current);
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
onPressIn,
|
|
328
|
+
onPressOut
|
|
329
|
+
}), [editable, hitSlop, onPress, onPressIn, onPressOut, rejectResponderTermination]);
|
|
330
|
+
|
|
331
|
+
// TextInput handles onBlur and onFocus events
|
|
332
|
+
// so omitting onBlur and onFocus pressability handlers here.
|
|
333
|
+
//
|
|
334
|
+
// Same logic as https://github.com/react/react-native/blob/v0.86.2/packages/react-native/Libraries/Components/TextInput/TextInput.js#L629
|
|
335
|
+
const {
|
|
336
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
337
|
+
onBlur: _onBlur,
|
|
338
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
339
|
+
onFocus: _onFocus,
|
|
340
|
+
...pressabilityHandlers
|
|
341
|
+
} = usePressability(pressabilityConfig) ?? {};
|
|
290
342
|
const handleRequestMarkdownResult = useCallback(e => {
|
|
291
343
|
const {
|
|
292
344
|
requestId,
|
|
@@ -402,6 +454,7 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
402
454
|
autoFocus: autoFocus,
|
|
403
455
|
scrollEnabled: scrollEnabled,
|
|
404
456
|
blockSyntax: blockSyntax,
|
|
457
|
+
markdownShortcuts: normalizedMarkdownShortcuts,
|
|
405
458
|
autoCapitalize: autoCapitalize,
|
|
406
459
|
interceptPaste: interceptPaste === true && onPaste != null,
|
|
407
460
|
multiline: multiline,
|
|
@@ -430,8 +483,13 @@ export const EnrichedMarkdownTextInput = ({
|
|
|
430
483
|
writingDirection: writingDirection,
|
|
431
484
|
onStartMention: handleStartMention,
|
|
432
485
|
onChangeMention: handleChangeMention,
|
|
433
|
-
onEndMention: handleEndMention
|
|
434
|
-
|
|
486
|
+
onEndMention: handleEndMention
|
|
487
|
+
// Explicitly pass through hitSlop because the native view subclasses
|
|
488
|
+
// RCTViewComponentView and makes use of hitSlop too
|
|
489
|
+
,
|
|
490
|
+
hitSlop: hitSlop,
|
|
491
|
+
...rest,
|
|
492
|
+
...pressabilityHandlers
|
|
435
493
|
});
|
|
436
494
|
};
|
|
437
495
|
export default EnrichedMarkdownTextInput;
|