react-native-enriched-markdown-scaffold 0.7.4-scaffold.9 → 1.0.2-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/README.md +54 -8
- package/ReactNativeEnrichedMarkdown.podspec +82 -73
- package/android/build.gradle +186 -1
- package/android/consumer-rules.pro +1 -1
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +9 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerDelegate.java +24 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +8 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +9 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +3 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +75 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +63 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +35 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +886 -23
- package/android/src/main/baseline-prof.txt +1 -1
- package/android/src/main/cpp/jni-adapter.cpp +74 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +189 -13
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +50 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +48 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextLayoutManager.kt +10 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +42 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +82 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/events/CopyPressEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputManager.kt +54 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +901 -462
- package/android/src/main/java/com/swmansion/enriched/markdown/input/MarkdownClipboard.kt +42 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/BlockEditCoordinator.kt +196 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/ClipboardCoordinator.kt +73 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditContext.kt +19 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditPipeline.kt +248 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditSession.kt +52 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/InputConnectionWrapper.kt +101 -7
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/LinkCoordinator.kt +69 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MarkdownTextWatcher.kt +3 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MentionCoordinator.kt +118 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnChangeStateEvent.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnContextMenuItemPressEvent.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnInputKeyPressEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/events/OnPasteEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/BlockStore.kt +254 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/FormattingStore.kt +80 -87
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputFormatter.kt +109 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputParser.kt +116 -22
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/MarkdownSerializer.kt +167 -38
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/RangeEditAdjustment.kt +149 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputEventEmitter.kt +66 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputMeasurementStore.kt +4 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/BlockRange.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/BlockType.kt +48 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/FormattingRange.kt +9 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/InputFormatterStyle.kt +39 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathAtom.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathChipStyle.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MutableRangeBounds.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputBulletSpan.kt +82 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputHeadingSpan.kt +58 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputListItemSpacingSpan.kt +37 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/spans/InputOrderedListMarkerSpan.kt +63 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/BlockHandler.kt +54 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/HeadingBlockHandler.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/OrderedListBlockHandler.kt +38 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/styles/UnorderedListBlockHandler.kt +37 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/toolbar/InputContextMenu.kt +8 -26
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/MarkdownASTNode.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockStyleContext.kt +9 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteRenderer.kt +100 -12
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeBlockRenderer.kt +16 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HeadingRenderer.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListContextManager.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListItemRenderer.kt +74 -18
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListRenderer.kt +43 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +9 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SoftBreakRenderer.kt +16 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SpanStyleCache.kt +30 -27
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/BaseListSpan.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/BlockquoteSpan.kt +174 -24
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBackgroundSpan.kt +27 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBlockSpan.kt +13 -16
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/EmphasisSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ImageSpan.kt +182 -46
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ListItemSpacingSpan.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ListMarkerAnchorSpan.kt +38 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/OrderedListSpan.kt +2 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/StrongSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/TaskListSpan.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/UnorderedListSpan.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/BlockquoteStyle.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/CodeBlockStyle.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ImageStyle.kt +7 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ListStyle.kt +4 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleConfig.kt +13 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/TableStyle.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/CodeBlockHighlighter.kt +90 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/CodeBlockNode.kt +57 -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/MarkdownSegment.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +37 -7
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/ReadableMapExtensions.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/RenderedSegment.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/SegmentSignature.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/StreamingMarkdownFilter.kt +83 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/MarkdownStyleParser.kt +74 -44
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/PasteTextUtils.kt +20 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/ImageCache.kt +26 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/ImageDownloader.kt +22 -9
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/LocalImageLoader.kt +161 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/TextPaintExtensions.kt +23 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/interaction/CheckboxTouchHelper.kt +7 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/interaction/TaskListTapUtils.kt +41 -21
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/BlockSpacing.kt +15 -8
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLongPressMovementMethod.kt +58 -27
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionActionMode.kt +49 -15
- package/android/src/main/java/com/swmansion/enriched/markdown/views/BlockMenuOptions.kt +45 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/CodeBlockContainerView.kt +396 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/ContextMenuPopup.kt +9 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/views/CopyGlyph.kt +101 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/TableContainerView.kt +36 -9
- package/android/src/main/jni/CMakeLists.txt +53 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownContainerShadowNode.cpp +10 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownContainerShadowNode.h +11 -2
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextShadowNode.cpp +10 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextShadowNode.h +12 -2
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextState.cpp +9 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextState.h +24 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/conversions.h +16 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/input/math/MathChipControllerImpl.kt +21 -4
- package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +7 -2
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathChipSpan.kt +1 -1
- package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +6 -4
- package/cpp/highlight/CodeBlockHighlighter.cpp +284 -0
- package/cpp/highlight/CodeBlockHighlighter.hpp +66 -0
- package/cpp/highlight/CodeBlockLanguages.cpp +138 -0
- package/cpp/highlight/CodeBlockLanguages.hpp +25 -0
- package/cpp/highlight/HighlightGrammars.hpp +28 -0
- package/cpp/highlight/code_highlight_podspec.rb +211 -0
- package/cpp/highlight/gen-registry.mjs +155 -0
- package/cpp/highlight/grammar-versions.json +159 -0
- package/cpp/highlight/vendor/generated/generated_queries.h +1665 -0
- package/cpp/highlight/vendor/generated/generated_registry.cpp +59 -0
- package/cpp/parser/MD4CParser.cpp +173 -61
- package/cpp/parser/MD4CParser.hpp +1 -0
- package/cpp/parser/MarkdownASTNode.hpp +2 -1
- package/cpp/wasm/ASTSerializer.cpp +2 -0
- package/cpp/wasm/build.sh +1 -0
- package/cpp/wasm/md4c_wasm.cpp +3 -1
- package/docs/ACCESSIBILITY.md +14 -2
- package/docs/API_REFERENCE.md +234 -12
- package/docs/BREAKING_CHANGES.md +129 -0
- package/docs/CODE_HIGHLIGHT.md +133 -0
- package/docs/COPY_OPTIONS.md +47 -3
- package/docs/ELEMENTS_STRUCTURE.md +52 -4
- package/docs/IMAGE_CACHING.md +30 -0
- package/docs/INPUT.md +108 -11
- package/docs/LATEX_MATH.md +87 -45
- package/docs/MACOS.md +1 -1
- package/docs/MARKDOWN_STREAMING.md +27 -1
- package/docs/NATIVE_ASSETS.md +127 -0
- package/docs/RTL.md +1 -1
- package/docs/STYLES.md +46 -6
- package/docs/TESTING.md +112 -0
- package/docs/TEXT.md +16 -6
- package/docs/WEB.md +3 -1
- package/ios/EnrichedMarkdown.h +7 -0
- package/ios/EnrichedMarkdown.mm +284 -75
- package/ios/EnrichedMarkdownText.h +7 -0
- package/ios/EnrichedMarkdownText.mm +101 -73
- package/ios/attachments/ENRMImageAttachment.h +9 -0
- package/ios/attachments/ENRMImageAttachment.m +143 -40
- package/ios/attachments/ENRMMathInlineAttachment.h +2 -0
- package/ios/attachments/ENRMMathInlineAttachment.m +48 -81
- package/ios/attachments/ENRMMathInlineAttachmentShared.h +2 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +75 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +63 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +35 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +886 -23
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/RCTComponentViewHelpers.h +131 -0
- package/ios/input/ENRMAutoLinkDetector.h +2 -1
- package/ios/input/ENRMAutoLinkDetector.mm +79 -41
- package/ios/input/ENRMBlockEditCoordinator.h +71 -0
- package/ios/input/ENRMBlockEditCoordinator.mm +195 -0
- package/ios/input/ENRMBlockRange.h +28 -0
- package/ios/input/ENRMBlockRange.mm +30 -0
- package/ios/input/ENRMBlockStore.h +56 -0
- package/ios/input/ENRMBlockStore.mm +275 -0
- package/ios/input/ENRMClipboardCoordinator.h +45 -0
- package/ios/input/ENRMClipboardCoordinator.mm +120 -0
- package/ios/input/ENRMDetectorPipeline.h +2 -1
- package/ios/input/ENRMEditPipeline.h +76 -0
- package/ios/input/ENRMEditPipeline.mm +228 -0
- package/ios/input/ENRMEditSession.h +36 -0
- package/ios/input/ENRMEditSession.mm +63 -0
- package/ios/input/ENRMFormattingStore.h +17 -0
- package/ios/input/ENRMFormattingStore.mm +95 -105
- package/ios/input/ENRMInputBlockType.h +91 -0
- package/ios/input/ENRMInputBlockType.mm +5 -0
- package/ios/input/ENRMInputDecorationDrawer.h +18 -0
- package/ios/input/ENRMInputEventEmitter.h +56 -0
- package/ios/input/ENRMInputEventEmitter.mm +308 -0
- package/ios/input/ENRMInputFormatter.h +29 -69
- package/ios/input/ENRMInputFormatter.mm +216 -124
- package/ios/input/ENRMInputFormatterStyle.h +99 -0
- package/ios/input/ENRMInputFormatterStyle.mm +188 -0
- package/ios/input/ENRMInputLayoutManager.h +9 -0
- package/ios/input/ENRMInputLayoutManager.mm +30 -0
- package/ios/input/ENRMInputListMarkerDrawer.h +32 -0
- package/ios/input/ENRMInputListMarkerDrawer.mm +426 -0
- package/ios/input/ENRMInputParser.h +5 -6
- package/ios/input/ENRMInputParser.mm +461 -178
- package/ios/input/ENRMInputRemend.mm +2 -2
- package/ios/input/ENRMInputStyleStateBuilder.h +40 -0
- package/ios/input/ENRMInputStyleStateBuilder.mm +60 -0
- package/ios/input/ENRMInputTextView.mm +103 -8
- package/ios/input/ENRMInputTypingAttributesController.h +42 -0
- package/ios/input/ENRMInputTypingAttributesController.mm +203 -0
- package/ios/input/ENRMLinkCoordinator.h +41 -0
- package/ios/input/ENRMLinkCoordinator.mm +89 -0
- package/ios/input/ENRMMarkdownSerializer.h +29 -5
- package/ios/input/ENRMMarkdownSerializer.mm +170 -48
- package/ios/input/ENRMMathAtom.h +26 -0
- package/ios/input/ENRMMathAtom.mm +12 -0
- package/ios/input/ENRMMentionCoordinator.h +45 -0
- package/ios/input/ENRMMentionCoordinator.mm +167 -0
- package/ios/input/ENRMRangeEditAdjustment.h +38 -0
- package/ios/input/ENRMRangeEditAdjustment.mm +91 -0
- package/ios/input/ENRMRangeStoreUtils.h +39 -0
- package/ios/input/EnrichedMarkdownTextInput+ContextMenu.mm +6 -6
- package/ios/input/EnrichedMarkdownTextInput+Internal.h +11 -3
- package/ios/input/EnrichedMarkdownTextInput.h +7 -1
- package/ios/input/EnrichedMarkdownTextInput.mm +1089 -1023
- package/ios/input/InputStylePropsUtils.h +109 -68
- package/ios/input/internals/EnrichedMarkdownTextInputShadowNode.mm +2 -1
- package/ios/input/styles/ENRMBlockHandler.h +46 -0
- package/ios/input/styles/ENRMHeadingBlockHandler.h +15 -0
- package/ios/input/styles/ENRMHeadingBlockHandler.mm +38 -0
- package/ios/input/styles/ENRMOrderedListBlockHandler.h +14 -0
- package/ios/input/styles/ENRMOrderedListBlockHandler.mm +48 -0
- package/ios/input/styles/ENRMUnorderedListBlockHandler.h +15 -0
- package/ios/input/styles/ENRMUnorderedListBlockHandler.mm +51 -0
- package/ios/internals/ENRMViewFreeMeasurement.h +331 -0
- package/ios/internals/EnrichedMarkdownShadowNode.h +1 -3
- package/ios/internals/EnrichedMarkdownShadowNode.mm +16 -20
- package/ios/internals/EnrichedMarkdownTextShadowNode.h +1 -3
- package/ios/internals/EnrichedMarkdownTextShadowNode.mm +15 -20
- package/ios/internals/MeasurementCache.h +33 -7
- package/ios/internals/ShadowMeasurementUtils.h +63 -58
- package/ios/math/ENRMMathChipController.h +74 -0
- package/ios/math/ENRMMathChipController.mm +476 -0
- package/ios/math/ENRMRaTeXBridge.swift +4 -1
- package/ios/parser/ENRMMarkdownParser.h +1 -8
- package/ios/parser/ENRMMarkdownParser.mm +2 -11
- package/ios/parser/MarkdownASTNode.h +2 -1
- package/ios/parser/MarkdownParserBridge.mm +4 -0
- package/ios/renderer/AttributedRenderer.m +20 -2
- package/ios/renderer/BaseRenderer.h +17 -2
- package/ios/renderer/BaseRenderer.m +30 -0
- package/ios/renderer/BlockquoteRenderer.h +1 -1
- package/ios/renderer/BlockquoteRenderer.m +144 -35
- package/ios/renderer/CodeBlockRenderer.h +1 -1
- package/ios/renderer/CodeBlockRenderer.m +27 -23
- package/ios/renderer/CodeRenderer.h +1 -1
- package/ios/renderer/CodeRenderer.m +3 -1
- package/ios/renderer/ENRMImageRenderer.h +1 -1
- package/ios/renderer/ENRMImageRenderer.m +5 -1
- package/ios/renderer/ENRMMathInlineRenderer.h +1 -1
- package/ios/renderer/ENRMMathInlineRenderer.m +5 -1
- package/ios/renderer/ENRMSpoilerRenderer.h +1 -1
- package/ios/renderer/ENRMSpoilerRenderer.m +3 -1
- package/ios/renderer/EmphasisRenderer.h +1 -1
- package/ios/renderer/EmphasisRenderer.m +3 -1
- package/ios/renderer/HeadingRenderer.h +1 -1
- package/ios/renderer/HeadingRenderer.m +13 -6
- package/ios/renderer/HighlightRenderer.h +1 -1
- package/ios/renderer/HighlightRenderer.m +3 -1
- package/ios/renderer/LinkRenderer.h +1 -1
- package/ios/renderer/LinkRenderer.m +3 -1
- package/ios/renderer/ListItemRenderer.h +13 -1
- package/ios/renderer/ListItemRenderer.m +102 -44
- package/ios/renderer/ListRenderer.h +2 -2
- package/ios/renderer/ListRenderer.m +63 -25
- package/ios/renderer/ParagraphRenderer.h +1 -1
- package/ios/renderer/ParagraphRenderer.m +16 -8
- package/ios/renderer/RenderContext.h +10 -0
- package/ios/renderer/RenderContext.m +44 -0
- package/ios/renderer/RendererFactory.m +14 -0
- package/ios/renderer/StrikethroughRenderer.h +1 -1
- package/ios/renderer/StrikethroughRenderer.m +3 -1
- package/ios/renderer/StrongRenderer.h +1 -1
- package/ios/renderer/StrongRenderer.m +3 -1
- package/ios/renderer/SubscriptRenderer.h +1 -1
- package/ios/renderer/SubscriptRenderer.m +3 -1
- package/ios/renderer/SuperscriptRenderer.h +1 -1
- package/ios/renderer/SuperscriptRenderer.m +3 -1
- package/ios/renderer/TextRenderer.h +2 -2
- package/ios/renderer/TextRenderer.m +3 -1
- package/ios/renderer/ThematicBreakRenderer.h +1 -1
- package/ios/renderer/ThematicBreakRenderer.m +3 -1
- package/ios/renderer/UnderlineRenderer.h +1 -1
- package/ios/renderer/UnderlineRenderer.m +3 -1
- package/ios/styles/StyleConfig.h +22 -0
- package/ios/styles/StyleConfig.mm +132 -0
- package/ios/utils/BlockquoteBorder.h +6 -0
- package/ios/utils/BlockquoteBorder.m +249 -52
- package/ios/utils/CodeBlockBackground.m +16 -2
- package/ios/utils/ENRMAtomicSize.h +65 -0
- package/ios/utils/ENRMBlockMenu.h +57 -0
- package/ios/utils/ENRMCodeBlockContent.h +37 -0
- package/ios/utils/ENRMCodeBlockContent.mm +79 -0
- package/ios/utils/ENRMCodeBlockHighlighter.h +37 -0
- package/ios/utils/ENRMCodeBlockHighlighter.mm +51 -0
- package/ios/utils/ENRMFeatureFlags.h +7 -0
- package/ios/utils/ENRMImageDownloader.h +11 -1
- package/ios/utils/ENRMImageDownloader.m +60 -16
- package/ios/utils/ENRMLocalImageLoader.h +31 -0
- package/ios/utils/ENRMLocalImageLoader.m +68 -0
- package/ios/utils/ENRMMathFallback.h +26 -0
- package/ios/utils/ENRMMathFallback.m +18 -0
- package/ios/utils/ENRMTextViewSetup.h +35 -17
- package/ios/utils/EditMenuUtils.h +22 -5
- package/ios/utils/EditMenuUtils.m +53 -9
- package/ios/utils/ImageRequestHeaderUtils.h +35 -0
- package/ios/utils/LastElementUtils.h +1 -0
- package/ios/utils/ListMarkerDrawer.m +29 -42
- package/ios/utils/MarkdownASTSerializer.m +4 -0
- package/ios/utils/ParagraphStyleUtils.h +5 -0
- package/ios/utils/ParagraphStyleUtils.m +77 -17
- package/ios/utils/RenderedMarkdownSegment.h +13 -1
- package/ios/utils/RenderedMarkdownSegment.m +20 -0
- package/ios/utils/SegmentRenderer.m +17 -4
- package/ios/utils/StreamingMarkdownFilter.h +11 -1
- package/ios/utils/StreamingMarkdownFilter.m +98 -2
- package/ios/utils/StylePropsUtils.h +63 -0
- package/ios/utils/TaskListTapUtils.m +24 -0
- package/ios/views/ENRMCodeBlockContainerView.h +53 -0
- package/ios/views/ENRMCodeBlockContainerView.m +559 -0
- package/ios/views/ENRMMathContainerView.h +16 -0
- package/ios/views/ENRMMathContainerView.m +74 -19
- package/ios/views/TableContainerView.h +22 -0
- package/ios/views/TableContainerView.m +261 -175
- package/jest.d.ts +1 -0
- package/jest.js +5 -0
- package/lib/module/EnrichedMarkdownNativeComponent.ts +73 -0
- package/lib/module/EnrichedMarkdownTextInput.js +84 -5
- package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
- package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +78 -5
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +74 -0
- package/lib/module/headingDefaults.js +34 -0
- package/lib/module/headingDefaults.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +191 -0
- package/lib/module/jest/index.js.map +1 -0
- package/lib/module/native/EnrichedMarkdownText.js +37 -5
- package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.js +81 -19
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.web.js +56 -18
- package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
- package/lib/module/normalizeMarkdownTextInputStyle.js +62 -15
- package/lib/module/normalizeMarkdownTextInputStyle.js.map +1 -1
- package/lib/module/normalizeMenuItem.js +1 -1
- package/lib/module/utils/textInputState.js +26 -0
- package/lib/module/utils/textInputState.js.map +1 -0
- package/lib/module/web/EnrichedMarkdownText.js +9 -5
- package/lib/module/web/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/web/parseMarkdown.js +4 -3
- package/lib/module/web/parseMarkdown.js.map +1 -1
- package/lib/module/web/renderers/InlineRenderers.js +6 -0
- package/lib/module/web/renderers/InlineRenderers.js.map +1 -1
- package/lib/module/web/renderers/ListRenderers.js +7 -2
- package/lib/module/web/renderers/ListRenderers.js.map +1 -1
- package/lib/module/web/renderers/index.js +7 -4
- package/lib/module/web/renderers/index.js.map +1 -1
- package/lib/module/web/styles.js +83 -6
- package/lib/module/web/styles.js.map +1 -1
- package/lib/module/web/utils.js +1 -0
- package/lib/module/web/utils.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 +66 -0
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +94 -9
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +69 -5
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +66 -0
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/headingDefaults.d.ts +9 -0
- package/lib/typescript/src/headingDefaults.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -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 +6 -0
- package/lib/typescript/src/jest/index.d.ts.map +1 -0
- 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/normalizeMarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts +19 -5
- package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts +72 -0
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +27 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.d.ts +104 -9
- package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +19 -0
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -1
- package/lib/typescript/src/types/events.d.ts +19 -0
- package/lib/typescript/src/types/events.d.ts.map +1 -1
- package/lib/typescript/src/utils/textInputState.d.ts +24 -0
- package/lib/typescript/src/utils/textInputState.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/parseMarkdown.d.ts +1 -1
- package/lib/typescript/src/web/parseMarkdown.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/InlineRenderers.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/ListRenderers.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/index.d.ts +2 -1
- package/lib/typescript/src/web/renderers/index.d.ts.map +1 -1
- package/lib/typescript/src/web/styles.d.ts +2 -1
- package/lib/typescript/src/web/styles.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +6 -2
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/lib/typescript/src/web/utils.d.ts.map +1 -1
- package/package.json +36 -9
- package/postinstall.mjs +131 -0
- package/ratex-version.json +21 -0
- package/src/EnrichedMarkdownNativeComponent.ts +73 -0
- package/src/EnrichedMarkdownTextInput.tsx +159 -8
- package/src/EnrichedMarkdownTextInputNativeComponent.ts +78 -5
- package/src/EnrichedMarkdownTextNativeComponent.ts +74 -0
- package/src/headingDefaults.ts +21 -0
- package/src/index.tsx +9 -0
- package/src/index.web.tsx +1 -0
- package/src/jest/index.tsx +215 -0
- package/src/native/EnrichedMarkdownText.tsx +53 -2
- package/src/normalizeMarkdownStyle.ts +102 -16
- package/src/normalizeMarkdownStyle.web.ts +63 -15
- package/src/normalizeMarkdownTextInputStyle.ts +110 -35
- package/src/normalizeMenuItem.ts +1 -1
- package/src/types/MarkdownStyle.ts +74 -0
- package/src/types/MarkdownStyleInternal.ts +39 -0
- package/src/types/MarkdownTextProps.ts +101 -9
- package/src/types/MarkdownTextProps.web.ts +19 -0
- package/src/types/events.ts +21 -0
- package/src/utils/textInputState.ts +35 -0
- package/src/web/EnrichedMarkdownText.tsx +16 -2
- package/src/web/parseMarkdown.ts +6 -2
- package/src/web/renderers/InlineRenderers.tsx +5 -0
- package/src/web/renderers/ListRenderers.tsx +14 -2
- package/src/web/renderers/index.tsx +6 -2
- package/src/web/styles.ts +89 -5
- package/src/web/types.ts +6 -1
- package/src/web/utils.ts +1 -0
- package/src/web/wasm/md4c.js +0 -0
- package/vendor-grammars.mjs +511 -0
- package/vendor-ratex.mjs +173 -0
- package/app.plugin.js +0 -2
- package/plugin/build/withAndroidMath.js +0 -19
- package/plugin/build/withIosMath.js +0 -28
- package/plugin/build/withReactNativeEnrichedMarkdown.js +0 -11
- package/plugin/src/withAndroidMath.ts +0 -24
- package/plugin/src/withIosMath.ts +0 -35
- package/plugin/src/withReactNativeEnrichedMarkdown.ts +0 -17
- package/plugin/tsconfig.build.json +0 -16
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Native assets (install-time download)
|
|
2
|
+
|
|
3
|
+
Two pieces of the library's native layer are large prebuilt/vendored assets: the
|
|
4
|
+
tree-sitter runtime and grammar sources used for [code-block highlighting](./CODE_HIGHLIGHT.md)
|
|
5
|
+
(~170 MB of C source across every supported grammar) and the RaTeX static XCFramework used for
|
|
6
|
+
[iOS LaTeX math](./LATEX_MATH.md) (~47 MB). Shipping them inside the npm tarball would make every
|
|
7
|
+
install download ~230 MB even for apps that use neither feature.
|
|
8
|
+
|
|
9
|
+
Instead they are **downloaded once at install time** by a `postinstall` script, keeping the
|
|
10
|
+
published package small (~1 MB packed / ~7.5 MB unpacked). The download is verified by sha256 and is
|
|
11
|
+
idempotent — a `.stamp` fingerprint in each vendor directory makes repeated installs a no-op.
|
|
12
|
+
|
|
13
|
+
## What gets downloaded, and from where
|
|
14
|
+
|
|
15
|
+
| Asset | Source | Used by |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| tree-sitter runtime | GitHub release tarball (`github.com/tree-sitter/tree-sitter`) | code highlighting (iOS + Android) |
|
|
18
|
+
| grammar sources (`parser.c`/`scanner.c`/`highlights.scm`) | npm registry (`registry.npmjs.org`) | code highlighting (iOS + Android) |
|
|
19
|
+
| RaTeX XCFramework + fonts | GitHub release (`github.com/erweixin/RaTeX`) | LaTeX math (iOS only) |
|
|
20
|
+
|
|
21
|
+
The pins live in `grammar-versions.json` and `ratex-version.json` inside the installed package. The
|
|
22
|
+
pre-built highlight registry for the default language set **is** shipped in the tarball, so the only
|
|
23
|
+
thing fetched for a default build is the grammar C source it compiles.
|
|
24
|
+
|
|
25
|
+
Files land under `node_modules/react-native-enriched-markdown-scaffold/` in
|
|
26
|
+
`cpp/highlight/vendor/` (grammars + runtime) and `ios/vendor/` (RaTeX). Because this runs during
|
|
27
|
+
`npm install` / `yarn add`, the assets are in place before `pod install` or the Android build reads
|
|
28
|
+
them.
|
|
29
|
+
|
|
30
|
+
## Requirements
|
|
31
|
+
|
|
32
|
+
- **Network access at install time** to `registry.npmjs.org` and `github.com`.
|
|
33
|
+
- `tar` (present on macOS, Linux, and Windows 10+). RaTeX also needs `unzip`; it is absent on stock
|
|
34
|
+
Windows, but RaTeX is iOS-only so this only affects Windows dev machines and is non-fatal.
|
|
35
|
+
|
|
36
|
+
The postinstall step **never fails the install**: if a download does not complete it prints a warning
|
|
37
|
+
and exits successfully. What the native build does when an asset is missing depends on whether you
|
|
38
|
+
**explicitly enabled** the feature in your app `package.json`:
|
|
39
|
+
|
|
40
|
+
- **On by default** (no `enriched-markdown` entry for it): the build treats the feature as disabled —
|
|
41
|
+
code highlighting compiles a no-op stub, iOS math is skipped with a CocoaPods warning — so the build
|
|
42
|
+
stays green.
|
|
43
|
+
- **Explicitly enabled** (`"enableMath": true` / `"enableCodeHighlight": true`): the build **fails with
|
|
44
|
+
an actionable error** telling you to re-run postinstall, because you asked for a feature whose assets
|
|
45
|
+
are not present.
|
|
46
|
+
|
|
47
|
+
To fix a missing download, re-run the recovery command below.
|
|
48
|
+
|
|
49
|
+
## Re-running or recovering
|
|
50
|
+
|
|
51
|
+
If a download didn't complete (offline, behind a firewall, or with scripts disabled), reinstall the
|
|
52
|
+
package to re-fetch the assets:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
npm rebuild react-native-enriched-markdown-scaffold
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
If your package manager blocks or skips that (pnpm, Yarn PnP, `--ignore-scripts`), run the vendor script
|
|
59
|
+
directly from your project root as a fallback:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
node node_modules/react-native-enriched-markdown-scaffold/postinstall.mjs
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Then re-run `pod install` (iOS) or rebuild (Android).
|
|
66
|
+
|
|
67
|
+
## Package-manager notes
|
|
68
|
+
|
|
69
|
+
- **npm / Yarn Classic / Yarn Berry (node-modules linker)**: works out of the box.
|
|
70
|
+
- **pnpm**: recent pnpm blocks dependency lifecycle scripts by default. Allow this package to run its
|
|
71
|
+
`postinstall` so the assets download — for example:
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
# pnpm-workspace.yaml (or package.json "pnpm" field)
|
|
75
|
+
onlyBuiltDependencies:
|
|
76
|
+
- react-native-enriched-markdown-scaffold
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Without this the native build fails until you run the recovery command above.
|
|
80
|
+
- **Yarn PnP** is not supported for this package — PnP stores dependencies as read-only archives, so
|
|
81
|
+
the postinstall cannot write the vendored assets into the package. Use the `node-modules` linker
|
|
82
|
+
(`nodeLinker: node-modules`), which is the norm for React Native projects anyway.
|
|
83
|
+
- **`--ignore-scripts`**: the assets will not download. Run the recovery command above afterward.
|
|
84
|
+
|
|
85
|
+
## Skipping the download (opt out)
|
|
86
|
+
|
|
87
|
+
If you don't use a feature, opt out in **your app's `package.json`** so the postinstall never
|
|
88
|
+
downloads its assets. Add an `enriched-markdown` block (both fields default to `true`):
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"enriched-markdown": {
|
|
93
|
+
"enableCodeHighlight": false,
|
|
94
|
+
"enableMath": false
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`enableCodeHighlight: false` skips the tree-sitter runtime + grammar download (iOS and Android);
|
|
100
|
+
`enableMath: false` skips the RaTeX download (iOS; Android math uses a Maven dependency and is
|
|
101
|
+
unaffected). The native build reads the same `enriched-markdown` block directly (iOS podspec /
|
|
102
|
+
Android `build.gradle`), so a `package.json` opt-out **also disables the feature at build time** — no
|
|
103
|
+
Podfile or `gradle.properties` edit needed. Disabling takes effect on the next `pod install` / native
|
|
104
|
+
rebuild; re-enabling also needs a reinstall so the assets download again.
|
|
105
|
+
|
|
106
|
+
> [!IMPORTANT]
|
|
107
|
+
> **Applying a change on iOS.** The podspec reads `package.json` at `pod install` time, not at build
|
|
108
|
+
> time, so a plain rebuild (`run-ios` / Xcode build) reuses the previously resolved pod — you must run
|
|
109
|
+
> `pod install` after editing the `enriched-markdown` block. And when you **change a feature that was
|
|
110
|
+
> already compiled in** (disabling it, or narrowing `codeHighlightLanguages`), also do a **clean build**
|
|
111
|
+
> (`Product > Clean Build Folder`, or delete the app's DerivedData): Xcode's incremental build does not
|
|
112
|
+
> reliably rebuild the pod's static library when only its source list changes, so it can otherwise link a
|
|
113
|
+
> stale copy that still contains the old code. Android reconfigures on every build and needs neither step.
|
|
114
|
+
|
|
115
|
+
**Which `package.json`?** The *download* opt-out is read from wherever the install runs (via `INIT_CWD`)
|
|
116
|
+
— in a monorepo that is the workspace root, and there is one shared `node_modules`, so the download
|
|
117
|
+
opt-out is global. The *build* flag is read from the **app's** `package.json` (the one beside `ios/` /
|
|
118
|
+
`android/`), so each app in a monorepo enables or disables features independently. Neither has any
|
|
119
|
+
effect inside this repo's own monorepo development.
|
|
120
|
+
|
|
121
|
+
## Disabling the features at build time
|
|
122
|
+
|
|
123
|
+
You can also disable a feature purely at build time (assets stay downloaded but are never
|
|
124
|
+
compiled/linked):
|
|
125
|
+
|
|
126
|
+
- Code highlighting: see [Choosing languages / reducing binary size](./CODE_HIGHLIGHT.md#choosing-languages--reducing-binary-size).
|
|
127
|
+
- LaTeX math: see [Disabling LaTeX Math](./LATEX_MATH.md#disabling-latex-math-reducing-bundle-size).
|
package/docs/RTL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# RTL Support
|
|
2
2
|
|
|
3
|
-
`react-native-enriched-markdown` resolves writing direction **per paragraph** on both platforms: each paragraph picks its own base direction from its first strong directional character. Arabic, Hebrew, and Persian content right-aligns automatically, even inside an LTR app and even when mixed with English paragraphs in the same document.
|
|
3
|
+
`react-native-enriched-markdown-scaffold` resolves writing direction **per paragraph** on both platforms: each paragraph picks its own base direction from its first strong directional character. Arabic, Hebrew, and Persian content right-aligns automatically, even inside an LTR app and even when mixed with English paragraphs in the same document.
|
|
4
4
|
|
|
5
5
|
This document describes the read-only [`EnrichedMarkdownText`](TEXT.md) renderer. The rich [`EnrichedMarkdownTextInput`](INPUT.md#rtl-support) follows the same per-paragraph rules — see its [RTL section](INPUT.md#rtl-support) for input-specific caveats (placeholder, code blocks, etc.).
|
|
6
6
|
|
package/docs/STYLES.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Style Properties Reference
|
|
2
2
|
|
|
3
|
-
This document provides a comprehensive reference for all style properties available in `react-native-enriched-markdown`.
|
|
3
|
+
This document provides a comprehensive reference for all style properties available in `react-native-enriched-markdown-scaffold`.
|
|
4
4
|
|
|
5
5
|
## Platform Defaults
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ The library provides sensible defaults optimized for each platform:
|
|
|
14
14
|
|
|
15
15
|
## Style Inheritance
|
|
16
16
|
|
|
17
|
-
`react-native-enriched-markdown` uses a base block style architecture where all block elements (paragraphs, headings, lists, blockquotes, code blocks) share a common set of typography properties. This base block style includes:
|
|
17
|
+
`react-native-enriched-markdown-scaffold` uses a base block style architecture where all block elements (paragraphs, headings, lists, blockquotes, code blocks) share a common set of typography properties. This base block style includes:
|
|
18
18
|
|
|
19
19
|
- `fontSize` - Font size in points
|
|
20
20
|
- `fontFamily` - Font family name
|
|
@@ -149,6 +149,8 @@ The library provides sensible default styles for all Markdown elements out of th
|
|
|
149
149
|
borderColor: '#007AFF',
|
|
150
150
|
borderWidth: 3,
|
|
151
151
|
backgroundColor: '#F0F8FF',
|
|
152
|
+
borderRadius: 8,
|
|
153
|
+
padding: 12,
|
|
152
154
|
marginBottom: 12,
|
|
153
155
|
},
|
|
154
156
|
list: {
|
|
@@ -209,7 +211,7 @@ The library provides sensible default styles for all Markdown elements out of th
|
|
|
209
211
|
> [!NOTE]
|
|
210
212
|
> **Performance:** Memoize the `markdownStyle` prop with `useMemo` to avoid unnecessary re-renders:
|
|
211
213
|
> ```tsx
|
|
212
|
-
> import type { MarkdownStyle } from 'react-native-enriched-markdown';
|
|
214
|
+
> import type { MarkdownStyle } from 'react-native-enriched-markdown-scaffold';
|
|
213
215
|
>
|
|
214
216
|
> const markdownStyle: MarkdownStyle = useMemo(() => ({
|
|
215
217
|
> paragraph: { fontSize: 16 },
|
|
@@ -225,8 +227,8 @@ To support dark mode, create `MarkdownStyle` objects for each color scheme and s
|
|
|
225
227
|
|
|
226
228
|
```tsx
|
|
227
229
|
import { useColorScheme } from 'react-native';
|
|
228
|
-
import { EnrichedMarkdownText } from 'react-native-enriched-markdown';
|
|
229
|
-
import type { MarkdownStyle } from 'react-native-enriched-markdown';
|
|
230
|
+
import { EnrichedMarkdownText } from 'react-native-enriched-markdown-scaffold';
|
|
231
|
+
import type { MarkdownStyle } from 'react-native-enriched-markdown-scaffold';
|
|
230
232
|
|
|
231
233
|
const lightMarkdownStyle: MarkdownStyle = {
|
|
232
234
|
blockquote: { backgroundColor: '#F9FAFB', borderColor: '#D1D5DB' },
|
|
@@ -295,6 +297,8 @@ function App() {
|
|
|
295
297
|
| `borderWidth` | `number` | Left border width |
|
|
296
298
|
| `gapWidth` | `number` | Gap between border and text |
|
|
297
299
|
| `backgroundColor` | `string` | Background color |
|
|
300
|
+
| `borderRadius` | `number` | Corner radius of the background box; accent borders are clipped to the rounded shape, nested quotes rounding against their own box (default: `0`) |
|
|
301
|
+
| `padding` | `number` | Inner top/bottom padding between the background edges and content, applied at every nesting level — also applies to the trailing edge on iOS and web (default: `0`) |
|
|
298
302
|
|
|
299
303
|
### List-specific
|
|
300
304
|
|
|
@@ -307,6 +311,7 @@ function App() {
|
|
|
307
311
|
| `markerFontWeight` | `string` | Number marker font weight |
|
|
308
312
|
| `gapWidth` | `number` | Gap between marker and text |
|
|
309
313
|
| `marginLeft` | `number` | Left margin for nesting |
|
|
314
|
+
| `itemSpacing` | `number` | Vertical spacing between consecutive items, including nested ones (default: `0`) |
|
|
310
315
|
|
|
311
316
|
### Code Block-specific
|
|
312
317
|
|
|
@@ -317,6 +322,34 @@ function App() {
|
|
|
317
322
|
| `borderRadius` | `number` | Corner radius |
|
|
318
323
|
| `borderWidth` | `number` | Border width |
|
|
319
324
|
| `padding` | `number` | Inner padding |
|
|
325
|
+
| `syntaxColors` | `object` | Per-token syntax highlight colors (see below) |
|
|
326
|
+
|
|
327
|
+
#### `syntaxColors`
|
|
328
|
+
|
|
329
|
+
Per-token foreground colors for syntax highlighting, keyed on the highlight token type. Any key you omit falls back to the default GitHub-light palette; `operator`, `punctuation`, `variable`, and `embedded` default to the code block's base `color` (i.e. no visible recolor). Colors only take visible effect when the optional syntax highlighting module is compiled in; otherwise code blocks render uncolored.
|
|
330
|
+
|
|
331
|
+
| Property | Type | Description |
|
|
332
|
+
|----------|------|-------------|
|
|
333
|
+
| `keyword` | `string` | Keywords (e.g. `if`, `return`) |
|
|
334
|
+
| `operator` | `string` | Operators (e.g. `+`, `=>`) |
|
|
335
|
+
| `punctuation` | `string` | Brackets, delimiters, punctuation |
|
|
336
|
+
| `string` | `string` | String and character literals |
|
|
337
|
+
| `number` | `string` | Numeric literals |
|
|
338
|
+
| `constant` | `string` | Constants and booleans |
|
|
339
|
+
| `comment` | `string` | Comments |
|
|
340
|
+
| `function` | `string` | Function and method names |
|
|
341
|
+
| `type` | `string` | Types and classes |
|
|
342
|
+
| `variable` | `string` | Variables and parameters |
|
|
343
|
+
| `property` | `string` | Object properties and fields |
|
|
344
|
+
| `tag` | `string` | Markup tags |
|
|
345
|
+
| `attribute` | `string` | Markup attributes |
|
|
346
|
+
| `embedded` | `string` | Embedded/injected language regions |
|
|
347
|
+
|
|
348
|
+
> [!NOTE]
|
|
349
|
+
> Inside list items, code blocks (background included) indent to the item's content column.
|
|
350
|
+
|
|
351
|
+
> [!NOTE]
|
|
352
|
+
> With `flavor="github"`, code blocks render as a block component with a header bar (language name on the left, copy-code button on the right) and a divider above the code. The header derives its appearance from the code block style: the label uses the system font at 0.85 x `fontSize`, and the label, button, and divider use `color` at reduced opacity. Dedicated header style properties may be added later.
|
|
320
353
|
|
|
321
354
|
### Inline Code-specific
|
|
322
355
|
|
|
@@ -392,11 +425,16 @@ Styles for highlighted text (`==text==`). Requires `md4cFlags={{ highlight: true
|
|
|
392
425
|
|
|
393
426
|
| Property | Type | Description |
|
|
394
427
|
|----------|------|-------------|
|
|
395
|
-
| `height` | `number` |
|
|
428
|
+
| `height` | `number` | Fixed image height (default sizing knob). |
|
|
429
|
+
| `maxHeight` | `number` | Maximum height the image is fitted into, preserving aspect ratio. Replaces `height` when set. |
|
|
430
|
+
| `aspectRatio` | `number` | Width / height ratio (e.g. `16 / 9`). Fills available width; height derived from the ratio. Ignores `height`/`maxHeight`. |
|
|
431
|
+
| `resizeMode` | `'contain' \| 'cover' \| 'stretch' \| 'center' \| 'none'` | How the image fills its box (like RN `resizeMode` / CSS `object-fit`). Applies whenever set explicitly, including with a fixed `height` box. When omitted, defaults to `'cover'` if `maxHeight` or `aspectRatio` is set; otherwise block images keep the legacy fill-width behavior. |
|
|
396
432
|
| `borderRadius` | `number` | Corner radius |
|
|
397
433
|
| `marginTop` | `number` | Top margin |
|
|
398
434
|
| `marginBottom` | `number` | Bottom margin |
|
|
399
435
|
|
|
436
|
+
> Sizing precedence: `aspectRatio` > `maxHeight` > `height`. `resizeMode` applies independently on top. When no new knob is set (`resizeMode`, `maxHeight`, or `aspectRatio`), block images keep the exact legacy fixed-`height` behavior.
|
|
437
|
+
|
|
400
438
|
### Inline Image-specific
|
|
401
439
|
|
|
402
440
|
| Property | Type | Description |
|
|
@@ -428,6 +466,8 @@ Table styles only apply when `flavor="github"` is set. Tables inherit the base b
|
|
|
428
466
|
| `borderRadius` | `number` | Corner radius of the table container |
|
|
429
467
|
| `cellPaddingHorizontal` | `number` | Horizontal padding inside cells |
|
|
430
468
|
| `cellPaddingVertical` | `number` | Vertical padding inside cells |
|
|
469
|
+
| `horizontalOverflow` | `number` | When set, scrollable tables extend beyond the markdown container by this amount on each side (edge-to-edge / "bleed" layout). Set to the parent's horizontal padding to make wide tables reach the screen edges. Has no effect on tables that fit within the container width. iOS, Android, and macOS only. Default: `0` |
|
|
470
|
+
| `align` | `'left' \| 'center' \| 'right'` | Horizontal alignment of the whole table when it is narrower than the container. Tables that overflow and scroll ignore it — scrolling always starts at the table's beginning. On web, setting any value (including `'left'`) also makes the table shrink to fit its content instead of filling the container width. Default: unset — legacy start-aligned placement (full-width table on web) |
|
|
431
471
|
|
|
432
472
|
### Task List-specific
|
|
433
473
|
|
package/docs/TESTING.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Testing with Jest
|
|
2
|
+
|
|
3
|
+
`EnrichedMarkdownTextInput` and `EnrichedMarkdownText` are Fabric/codegen native
|
|
4
|
+
components. Under Jest there is no native view manager, so rendering them — or
|
|
5
|
+
calling any imperative ref method such as `focus()`, `setValue()`, or
|
|
6
|
+
`toggleBold()`, which dispatch native commands — throws. To let you test screens
|
|
7
|
+
that embed these components, the package ships an importable mock that renders
|
|
8
|
+
plain React Native primitives and exposes every imperative method as a
|
|
9
|
+
[`jest.fn()`](https://jestjs.io/docs/mock-functions) spy.
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
Point Jest at the shipped mock from a setup file (for example `jest.setup.js`)
|
|
14
|
+
listed in your config's `setupFilesAfterEnv`:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
// jest.setup.js
|
|
18
|
+
jest.mock('react-native-enriched-markdown-scaffold', () =>
|
|
19
|
+
require('react-native-enriched-markdown-scaffold/jest'),
|
|
20
|
+
);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The mock is distributed as compiled ES modules, so — like most React Native
|
|
24
|
+
libraries — the package must be transformed by Jest. Add it to
|
|
25
|
+
`transformIgnorePatterns` in your Jest config:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
// jest.config.js
|
|
29
|
+
module.exports = {
|
|
30
|
+
preset: 'jest-expo', // or 'react-native'
|
|
31
|
+
transformIgnorePatterns: [
|
|
32
|
+
'node_modules/(?!((jest-)?react-native|@react-native(-community)?|expo(nent)?|@expo(nent)?/.*|react-native-enriched-markdown-scaffold))',
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## What the mock does
|
|
38
|
+
|
|
39
|
+
- **Renders a real `TextInput`.** React Native Testing Library queries
|
|
40
|
+
(`getByTestId`, `getByPlaceholderText`, …) and `fireEvent.changeText` work out
|
|
41
|
+
of the box. `EnrichedMarkdownText` renders its `markdown` prop as plain text.
|
|
42
|
+
- **Emits change events on user input.** Typing fires `onChangeText` and, when a
|
|
43
|
+
handler is provided, `onChangeMarkdown`. The mock cannot parse markdown, so it
|
|
44
|
+
forwards the raw text to `onChangeMarkdown` as a stand-in.
|
|
45
|
+
- **Mirrors `setValue` suppression.** Calling `setValue()` updates the rendered
|
|
46
|
+
text so the programmatic value is observable, but emits **no** change events —
|
|
47
|
+
matching the native component's suppression of emits for programmatic updates.
|
|
48
|
+
- **Exposes every imperative method as a spy.** `toggleBold`, `insertMention`,
|
|
49
|
+
`setSelection`, and the rest are `jest.fn()`s you can assert against. The async
|
|
50
|
+
methods resolve sensible values: `getMarkdown()` resolves the current text and
|
|
51
|
+
`getCaretRect()` resolves `{ x: 0, y: 0, width: 0, height: 0 }`.
|
|
52
|
+
|
|
53
|
+
The mock is authored against the library's real public types, so it is
|
|
54
|
+
type-checked against the actual component API on every release and cannot
|
|
55
|
+
silently fall behind when methods or props are added.
|
|
56
|
+
|
|
57
|
+
## Examples
|
|
58
|
+
|
|
59
|
+
Asserting user input reaches your handlers:
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { render, screen, fireEvent } from '@testing-library/react-native';
|
|
63
|
+
import { EnrichedMarkdownTextInput } from 'react-native-enriched-markdown-scaffold';
|
|
64
|
+
|
|
65
|
+
test('reports typed text', () => {
|
|
66
|
+
const onChangeMarkdown = jest.fn();
|
|
67
|
+
render(
|
|
68
|
+
<EnrichedMarkdownTextInput
|
|
69
|
+
testID="composer"
|
|
70
|
+
onChangeMarkdown={onChangeMarkdown}
|
|
71
|
+
/>,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
fireEvent.changeText(screen.getByTestId('composer'), 'hello');
|
|
75
|
+
|
|
76
|
+
expect(onChangeMarkdown).toHaveBeenCalledWith('hello');
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Asserting a toolbar button invokes the right imperative method:
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import { createRef } from 'react';
|
|
84
|
+
import { render, screen, fireEvent } from '@testing-library/react-native';
|
|
85
|
+
import {
|
|
86
|
+
EnrichedMarkdownTextInput,
|
|
87
|
+
type EnrichedMarkdownTextInputInstance,
|
|
88
|
+
} from 'react-native-enriched-markdown-scaffold';
|
|
89
|
+
|
|
90
|
+
test('bold button toggles bold', () => {
|
|
91
|
+
const ref = createRef<EnrichedMarkdownTextInputInstance>();
|
|
92
|
+
render(<EnrichedMarkdownTextInput ref={ref} />);
|
|
93
|
+
|
|
94
|
+
ref.current!.toggleBold();
|
|
95
|
+
|
|
96
|
+
expect(ref.current!.toggleBold).toHaveBeenCalledTimes(1);
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Reading a programmatic value back out:
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
ref.current!.setValue('**bold**');
|
|
104
|
+
await expect(ref.current!.getMarkdown()).resolves.toBe('**bold**');
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Limitations
|
|
108
|
+
|
|
109
|
+
The mock does not parse or render markdown formatting — it stores and echoes raw
|
|
110
|
+
text. It is meant for testing your components' wiring (event handlers, ref calls,
|
|
111
|
+
conditional rendering), not the library's rendering or parsing behavior, which is
|
|
112
|
+
covered by the library's own end-to-end tests.
|
package/docs/TEXT.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
### CommonMark (default)
|
|
8
8
|
|
|
9
9
|
```tsx
|
|
10
|
-
import { EnrichedMarkdownText } from 'react-native-enriched-markdown';
|
|
10
|
+
import { EnrichedMarkdownText } from 'react-native-enriched-markdown-scaffold';
|
|
11
11
|
import { Linking } from 'react-native';
|
|
12
12
|
|
|
13
13
|
const markdown = `
|
|
@@ -76,6 +76,16 @@ Task lists with interactive checkboxes are available when `flavor="github"` is s
|
|
|
76
76
|
/>
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
To render checkboxes that display their markdown state but cannot be toggled by the user, set [`enableTaskListItemToggle`](API_REFERENCE.md#enabletasklistitemtoggle) to `false`. The tap becomes fully inert — no visual toggle and no `onTaskListItemPress` — while text selection and links in the same row keep working.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<EnrichedMarkdownText
|
|
83
|
+
flavor="github"
|
|
84
|
+
markdown={content}
|
|
85
|
+
enableTaskListItemToggle={false}
|
|
86
|
+
/>
|
|
87
|
+
```
|
|
88
|
+
|
|
79
89
|
### Link Handling
|
|
80
90
|
|
|
81
91
|
Links in Markdown are interactive and can be handled with the `onLinkPress` and `onLinkLongPress` callbacks:
|
|
@@ -87,23 +97,23 @@ See the [API Reference](API_REFERENCE.md#onlinkpress) for detailed examples and
|
|
|
87
97
|
|
|
88
98
|
## Supported Markdown Elements
|
|
89
99
|
|
|
90
|
-
`react-native-enriched-markdown` supports a comprehensive set of Markdown elements. See [Element Structure](ELEMENTS_STRUCTURE.md) for a detailed overview of all supported elements, their syntax, block vs inline categorization, nesting behavior, and how elements inherit typography from their parent blocks.
|
|
100
|
+
`react-native-enriched-markdown-scaffold` supports a comprehensive set of Markdown elements. See [Element Structure](ELEMENTS_STRUCTURE.md) for a detailed overview of all supported elements, their syntax, block vs inline categorization, nesting behavior, and how elements inherit typography from their parent blocks.
|
|
91
101
|
|
|
92
102
|
## Copy Options
|
|
93
103
|
|
|
94
|
-
When text is selected, `react-native-enriched-markdown` provides enhanced copy functionality through the context menu. See [Copy Options](COPY_OPTIONS.md) for details on smart copy, copy as Markdown, and copy image URL features.
|
|
104
|
+
When text is selected, `react-native-enriched-markdown-scaffold` provides enhanced copy functionality through the context menu. See [Copy Options](COPY_OPTIONS.md) for details on smart copy, copy as Markdown, and copy image URL features.
|
|
95
105
|
|
|
96
106
|
## Accessibility
|
|
97
107
|
|
|
98
|
-
`react-native-enriched-markdown` provides comprehensive accessibility support for screen readers on both platforms. See [Accessibility](ACCESSIBILITY.md) for detailed information about VoiceOver and TalkBack support, custom rotors, semantic traits, and best practices.
|
|
108
|
+
`react-native-enriched-markdown-scaffold` provides comprehensive accessibility support for screen readers on both platforms. See [Accessibility](ACCESSIBILITY.md) for detailed information about VoiceOver and TalkBack support, custom rotors, semantic traits, and best practices.
|
|
99
109
|
|
|
100
110
|
## RTL Support
|
|
101
111
|
|
|
102
|
-
`react-native-enriched-markdown` fully supports right-to-left (RTL) languages such as Arabic, Hebrew, and Persian. See [RTL Support](RTL.md) for platform-specific setup instructions and how each element behaves in RTL contexts.
|
|
112
|
+
`react-native-enriched-markdown-scaffold` fully supports right-to-left (RTL) languages such as Arabic, Hebrew, and Persian. See [RTL Support](RTL.md) for platform-specific setup instructions and how each element behaves in RTL contexts.
|
|
103
113
|
|
|
104
114
|
## Customizing Styles
|
|
105
115
|
|
|
106
|
-
`react-native-enriched-markdown` allows customizing styles of all Markdown elements using the `markdownStyle` prop. See the [Style Properties Reference](STYLES.md) for a detailed overview of all available style properties.
|
|
116
|
+
`react-native-enriched-markdown-scaffold` allows customizing styles of all Markdown elements using the `markdownStyle` prop. See the [Style Properties Reference](STYLES.md) for a detailed overview of all available style properties.
|
|
107
117
|
|
|
108
118
|
### Dark Mode
|
|
109
119
|
|
package/docs/WEB.md
CHANGED
|
@@ -11,7 +11,8 @@ All core `EnrichedMarkdownText` features are supported on web, including:
|
|
|
11
11
|
- Full GFM: tables (with horizontal scroll), task lists (with checkbox interaction), strikethrough, links, images (block and inline), code blocks, LaTeX math (block and inline)
|
|
12
12
|
- All `markdownStyle` customisation options
|
|
13
13
|
- `onLinkPress`, `onLinkLongPress` (mapped to `contextmenu` event), `onTaskListItemPress` callbacks
|
|
14
|
-
- `
|
|
14
|
+
- `enableTaskListItemToggle` — set to `false` to render task list checkboxes read-only (the click is fully inert: no toggle, no `onTaskListItemPress`). The checkbox keeps its normal appearance, marked `readOnly` / `aria-disabled` and pointer-inert rather than `disabled`, matching iOS and Android
|
|
15
|
+
- `allowTrailingMargin`, `containerStyle`, `selectable`, `selectionColor`, `md4cFlags` (`underline`, `superscript`, `subscript`, `latexMath`, `highlight`, `hardSoftBreaks`)
|
|
15
16
|
- RTL support via the `dir` prop (CSS logical properties automatically flip blockquote borders, list indentation, etc.)
|
|
16
17
|
|
|
17
18
|
### Accessibility
|
|
@@ -41,6 +42,7 @@ The web implementation also exports `WebMarkdownTextProps` which extends `Enrich
|
|
|
41
42
|
| `streamingConfig` | Native-only streaming table configuration. Not yet implemented on web. |
|
|
42
43
|
| `contextMenuItems` | Not supported — browsers don't allow extending the native context menu. |
|
|
43
44
|
| `selectionMenuConfig` | Not supported — native-only built-in selection menu actions. |
|
|
45
|
+
| `contextMenuHidden` | Not supported — browsers own the context menu on selected text. |
|
|
44
46
|
| `selectionHandleColor` | Android-only — desktop browsers don't render selection handles. |
|
|
45
47
|
|
|
46
48
|
## Not supported on web
|
package/ios/EnrichedMarkdown.h
CHANGED
|
@@ -13,6 +13,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
13
13
|
- (void)renderMarkdownSynchronously:(NSString *)markdownString;
|
|
14
14
|
- (BOOL)hasRenderedMarkdown:(NSString *)markdown;
|
|
15
15
|
- (BOOL)hasRenderedWithStyleFingerprint:(size_t)fingerprint;
|
|
16
|
+
|
|
17
|
+
/// Size last committed by Fabric via `updateLayoutMetrics:`, readable from
|
|
18
|
+
/// any thread without blocking (issue #550: the shadow-node measure path must
|
|
19
|
+
/// never wait on the main thread, and reading `bounds` off-main is unsafe).
|
|
20
|
+
/// Backed by a single lock-free atomic, so the pair can't tear. Returns
|
|
21
|
+
/// CGSizeZero until the first layout is committed.
|
|
22
|
+
- (CGSize)lastCommittedLayoutSize;
|
|
16
23
|
@end
|
|
17
24
|
|
|
18
25
|
NS_ASSUME_NONNULL_END
|