react-native-enriched-markdown-scaffold 0.7.4-scaffold.8 → 1.0.2-scaffold.1
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 +191 -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 +27 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +9 -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 +40 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +839 -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 +175 -11
- 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 +62 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +911 -460
- 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/BlockSyntaxSentinel.kt +69 -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 +180 -27
- 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 +7 -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 +33 -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 +19 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/views/CodeBlockContainerView.kt +388 -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 +32 -5
- 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 +2 -0
- 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 +231 -8
- package/docs/BREAKING_CHANGES.md +129 -0
- package/docs/CODE_HIGHLIGHT.md +133 -0
- package/docs/COPY_OPTIONS.md +21 -3
- package/docs/ELEMENTS_STRUCTURE.md +52 -4
- package/docs/IMAGE_CACHING.md +30 -0
- package/docs/INPUT.md +146 -5
- 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 +262 -67
- package/ios/EnrichedMarkdownText.h +7 -0
- package/ios/EnrichedMarkdownText.mm +97 -68
- 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 +40 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +839 -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/ENRMBlockSyntaxSentinel.h +25 -0
- package/ios/input/ENRMBlockSyntaxSentinel.mm +80 -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 +10 -6
- package/ios/input/ENRMInputParser.mm +527 -171
- 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 +1104 -1024
- 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/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.m +22 -1
- 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 +46 -0
- package/ios/views/ENRMCodeBlockContainerView.m +566 -0
- package/ios/views/ENRMMathContainerView.h +12 -0
- package/ios/views/ENRMMathContainerView.m +71 -1
- package/ios/views/TableContainerView.h +18 -0
- package/ios/views/TableContainerView.m +259 -159
- package/jest.d.ts +1 -0
- package/jest.js +5 -0
- package/lib/module/EnrichedMarkdownNativeComponent.ts +65 -0
- package/lib/module/EnrichedMarkdownTextInput.js +86 -5
- package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
- package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +89 -5
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +66 -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 +30 -4
- 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 +62 -0
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +95 -9
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +80 -5
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +62 -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 +65 -1
- 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 +65 -0
- package/src/EnrichedMarkdownTextInput.tsx +162 -8
- package/src/EnrichedMarkdownTextInputNativeComponent.ts +89 -5
- package/src/EnrichedMarkdownTextNativeComponent.ts +66 -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 +40 -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 +65 -0
- 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
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# react-native-enriched-markdown-scaffold
|
|
2
2
|
|
|
3
|
-
> A fork of [`react-native-enriched-markdown`](https://github.com/software-mansion/
|
|
3
|
+
> A fork of [`react-native-enriched-markdown`](https://github.com/software-mansion/enriched-markdown). **Not official.**
|
|
4
4
|
|
|
5
5
|
## Why this exists
|
|
6
6
|
|
|
@@ -20,7 +20,49 @@ yarn add react-native-enriched-markdown-scaffold
|
|
|
20
20
|
npm i react-native-enriched-markdown-scaffold
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Peer deps (same as upstream): `react`, `react-native
|
|
23
|
+
Peer deps (same as upstream): `react`, `react-native`, and `katex` (optional — only needed on Web).
|
|
24
|
+
|
|
25
|
+
> The Expo config plugin was removed upstream, so `@expo/config-plugins` is **not** a peer dep any more.
|
|
26
|
+
> Configure the native features through `package.json` instead — see below.
|
|
27
|
+
|
|
28
|
+
## Native assets: read this before your first build
|
|
29
|
+
|
|
30
|
+
The tarball deliberately ships **without** the two heavy native assets — the tree-sitter grammar
|
|
31
|
+
sources (code highlighting, both platforms) and the RaTeX XCFramework (iOS LaTeX math). A
|
|
32
|
+
`postinstall` script downloads them into `node_modules/react-native-enriched-markdown-scaffold/`
|
|
33
|
+
on your machine.
|
|
34
|
+
|
|
35
|
+
That script **never fails your install**: a blocked download only prints a warning and exits 0. So
|
|
36
|
+
declare what you actually use in **your app's `package.json`** and the native build will fail loudly
|
|
37
|
+
instead of quietly shipping without math or highlighting:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"enriched-markdown": {
|
|
42
|
+
"enableMath": true,
|
|
43
|
+
"enableCodeHighlight": true
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- Both fields **default to `true`**, so leaving the block out still downloads and compiles both.
|
|
49
|
+
The difference is the failure mode: with an explicit `true`, a missing asset stops `pod install`
|
|
50
|
+
/ the Gradle build with an actionable message; without it, the build stays green and the feature
|
|
51
|
+
is silently absent at runtime.
|
|
52
|
+
- The key is `"enriched-markdown"` — **not** the package name. It is read under that exact name by
|
|
53
|
+
the podspec and `android/build.gradle`, so it does not change for this fork.
|
|
54
|
+
- Set a field to `false` to skip both the download and the compile.
|
|
55
|
+
|
|
56
|
+
**Two different `package.json` files are involved**, which matters in a monorepo: the *download*
|
|
57
|
+
opt-out is read from wherever the install ran (`INIT_CWD` — the workspace root, one shared
|
|
58
|
+
`node_modules`), while the *build* flag is read from the **app's** `package.json`, the one next to
|
|
59
|
+
`ios/` and `android/`. In a plain app they are the same file. In a monorepo they are not, and each
|
|
60
|
+
half fails in its own quiet way — a root-only block downloads assets that no app opts into, an
|
|
61
|
+
app-only block opts into assets that were never downloaded. Put the block in **both** when in doubt.
|
|
62
|
+
|
|
63
|
+
Full detail, including recovery commands, pnpm/Yarn PnP notes and the `pod install` + clean-build
|
|
64
|
+
caveat, is in `docs/NATIVE_ASSETS.md` inside the tarball. Every command in the bundled `docs/` is
|
|
65
|
+
rewritten at publish time to use this package's name, so you can copy-paste them as-is.
|
|
24
66
|
|
|
25
67
|
## Usage
|
|
26
68
|
|
|
@@ -35,18 +77,22 @@ import {
|
|
|
35
77
|
} from 'react-native-enriched-markdown-scaffold';
|
|
36
78
|
```
|
|
37
79
|
|
|
38
|
-
|
|
80
|
+
Documentation ships **inside the tarball** under `docs/` — use that copy rather than the upstream
|
|
81
|
+
site, because this fork adds editor-side APIs upstream does not have (the math chip:
|
|
82
|
+
`onMathPress`, `insertMath`/`updateMath`/`removeMath`, and the `inlineMath` / `math` input style
|
|
83
|
+
keys). Start with `docs/TEXT.md`, `docs/INPUT.md`, `docs/STYLES.md` and `docs/LATEX_MATH.md`;
|
|
84
|
+
`docs/BREAKING_CHANGES.md` lists what changed between scaffold releases.
|
|
85
|
+
|
|
86
|
+
Upstream's own docs, for anything this fork does not touch:
|
|
39
87
|
|
|
40
|
-
- README: https://github.com/software-mansion/
|
|
41
|
-
-
|
|
42
|
-
- Input component: [docs/INPUT.md](https://github.com/software-mansion/react-native-enriched-markdown/blob/main/docs/INPUT.md)
|
|
43
|
-
- Style reference: [docs/STYLES.md](https://github.com/software-mansion/react-native-enriched-markdown/blob/main/docs/STYLES.md)
|
|
88
|
+
- README: https://github.com/software-mansion/enriched-markdown
|
|
89
|
+
- Docs site: https://enriched.swmansion.com/markdown
|
|
44
90
|
|
|
45
91
|
## Versioning
|
|
46
92
|
|
|
47
93
|
`MAJOR.MINOR.PATCH-scaffold.N` — the leading `MAJOR.MINOR.PATCH` tracks the upstream version we forked from, `-scaffold.N` increments on every internal release.
|
|
48
94
|
|
|
49
|
-
Example: `0.
|
|
95
|
+
Example: `1.0.2-scaffold.1` = snapshot taken while upstream sat at `1.0.2`, first internal release.
|
|
50
96
|
|
|
51
97
|
## License
|
|
52
98
|
|
|
@@ -5,6 +5,11 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
|
5
5
|
monorepo = File.exist?(File.expand_path("../core/EnrichedMarkdownCore.podspec", __dir__))
|
|
6
6
|
cpp_root = monorepo ? "$(PODS_TARGET_SRCROOT)/../core/cpp" : "$(PODS_TARGET_SRCROOT)/cpp"
|
|
7
7
|
|
|
8
|
+
require File.join(__dir__, "cpp/highlight/code_highlight_podspec.rb")
|
|
9
|
+
# In the monorepo the C++ (including tree-sitter highlighting) compiles in the
|
|
10
|
+
# EnrichedMarkdownCore pod; only the published, core-less build compiles it here.
|
|
11
|
+
code_highlight = monorepo ? EnrichedMarkdownCodeHighlight.disabled : EnrichedMarkdownCodeHighlight.config(__dir__)
|
|
12
|
+
|
|
8
13
|
Pod::Spec.new do |s|
|
|
9
14
|
s.name = "ReactNativeEnrichedMarkdown"
|
|
10
15
|
s.version = package["version"]
|
|
@@ -14,7 +19,7 @@ Pod::Spec.new do |s|
|
|
|
14
19
|
s.authors = package["author"]
|
|
15
20
|
|
|
16
21
|
s.platforms = { :ios => min_ios_version_supported, :osx => '14.0' }
|
|
17
|
-
s.source = { :git => "https://github.com/software-mansion/
|
|
22
|
+
s.source = { :git => "https://github.com/software-mansion/enriched-markdown.git", :tag => "#{s.version}" }
|
|
18
23
|
|
|
19
24
|
if monorepo
|
|
20
25
|
s.private_header_files = "ios/**/*.h"
|
|
@@ -22,97 +27,101 @@ Pod::Spec.new do |s|
|
|
|
22
27
|
s.dependency "EnrichedMarkdownCore"
|
|
23
28
|
else
|
|
24
29
|
s.private_header_files = "ios/**/*.h", "cpp/**/*.{h,hpp}"
|
|
25
|
-
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}", "cpp/md4c/*.{c,h}", "cpp/parser/*.{hpp,cpp}"
|
|
30
|
+
s.source_files = ["ios/**/*.{h,m,mm,cpp,swift}", "cpp/md4c/*.{c,h}", "cpp/parser/*.{hpp,cpp}", "cpp/highlight/*.{hpp,cpp}"] + code_highlight[:source_files]
|
|
31
|
+
s.preserve_paths = "cpp/highlight/vendor/**/*" if code_highlight[:enabled]
|
|
26
32
|
end
|
|
27
33
|
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
|
|
34
|
+
# LaTeX math rendering (RaTeX, iOS only). RaTeX ships as a prebuilt static XCFramework
|
|
35
|
+
# vendored under ios/vendor (restored by vendor/vendor-ratex.mjs at postinstall); it
|
|
36
|
+
# links under CocoaPods default static linkage and needs neither `use_frameworks!` nor
|
|
37
|
+
# SPM interop.
|
|
38
|
+
#
|
|
39
|
+
# The app package.json "enriched-markdown" block is the source of truth; ENV is a
|
|
40
|
+
# deprecated fallback. `math_explicit` tracks an active opt-in (vs the implicit
|
|
41
|
+
# default), which decides the missing-framework behavior below.
|
|
42
|
+
config = EnrichedMarkdownConfig.consumer_config
|
|
43
|
+
ratex_present = File.directory?(File.join(__dir__, 'ios/vendor/RaTeX.xcframework'))
|
|
44
|
+
math_flag = ENV['ENRICHED_MARKDOWN_ENABLE_MATH']
|
|
31
45
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
if config.key?('enableMath')
|
|
47
|
+
math_requested = config['enableMath'] != false
|
|
48
|
+
math_explicit = math_requested
|
|
49
|
+
if math_flag
|
|
50
|
+
EnrichedMarkdownConfig.warn_once(:math_env, '[ReactNativeEnrichedMarkdown] DEPRECATED: ENV[\'ENRICHED_MARKDOWN_ENABLE_MATH\'] ' \
|
|
51
|
+
'is ignored when "enriched-markdown".enableMath is set in your package.json.')
|
|
52
|
+
end
|
|
53
|
+
elsif math_flag
|
|
54
|
+
EnrichedMarkdownConfig.warn_once(:math_env, '[ReactNativeEnrichedMarkdown] DEPRECATED: ENV[\'ENRICHED_MARKDOWN_ENABLE_MATH\'] ' \
|
|
55
|
+
'will be removed in a future version. Configure via "enriched-markdown".enableMath in your package.json instead.')
|
|
56
|
+
math_requested = math_flag == '1'
|
|
57
|
+
math_explicit = math_requested
|
|
58
|
+
else
|
|
59
|
+
math_requested = true
|
|
60
|
+
math_explicit = false
|
|
41
61
|
end
|
|
42
62
|
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
# RaTeX is downloaded at postinstall and kept out of the tarball. Reconcile the
|
|
64
|
+
# request with the vendored framework: an explicit opt-in with the framework missing
|
|
65
|
+
# fails loud; on by default but missing (a partial/failed download, or a monorepo root
|
|
66
|
+
# opt-out) falls back to a clean build without math.
|
|
67
|
+
enable_math = math_requested && ratex_present
|
|
68
|
+
if !math_requested
|
|
69
|
+
EnrichedMarkdownConfig.warn_once(:math_disabled, '[ReactNativeEnrichedMarkdown] LaTeX math disabled via ' \
|
|
70
|
+
'"enriched-markdown".enableMath = false in your app package.json.')
|
|
71
|
+
elsif !ratex_present
|
|
72
|
+
if math_explicit
|
|
73
|
+
raise '[ReactNativeEnrichedMarkdown] LaTeX math is enabled but the vendored RaTeX ' \
|
|
74
|
+
'XCFramework is missing at ios/vendor/RaTeX.xcframework. Reinstall to fetch it: ' \
|
|
75
|
+
'`npm rebuild react-native-enriched-markdown-scaffold`. ' \
|
|
76
|
+
'To disable math, set "enriched-markdown".enableMath = false in your app package.json. ' \
|
|
77
|
+
'Troubleshooting: https://github.com/software-mansion/enriched-markdown/blob/main/docs/NATIVE_ASSETS.md'
|
|
78
|
+
end
|
|
79
|
+
EnrichedMarkdownConfig.warn_once(:math_disabled, '[ReactNativeEnrichedMarkdown] LaTeX math disabled: the vendored RaTeX ' \
|
|
80
|
+
'XCFramework was not found at ios/vendor/RaTeX.xcframework. If this is unintended, re-run ' \
|
|
81
|
+
'`node node_modules/react-native-enriched-markdown-scaffold/postinstall.mjs`.')
|
|
45
82
|
end
|
|
46
83
|
|
|
47
|
-
|
|
84
|
+
# The RaTeX XCFramework bundles its own module.modulemap and headers; never let the
|
|
85
|
+
# broad ios/**/*.h and ios/**/*.swift globs treat its internals as pod sources.
|
|
86
|
+
exclude = ["ios/vendor/RaTeX.xcframework/**/*"]
|
|
87
|
+
# ios/math holds the RaTeX bridge; ios/vendor/*.swift are RaTeX's vendored core Swift
|
|
88
|
+
# sources. Both compile into this pod's module only when math is enabled.
|
|
89
|
+
exclude += ["ios/math/**/*.swift", "ios/vendor/*.swift"] unless enable_math
|
|
90
|
+
s.exclude_files = exclude
|
|
91
|
+
|
|
92
|
+
preprocessor_defs = "$(inherited) MD4C_USE_UTF8=1#{code_highlight[:defines]}"
|
|
48
93
|
if enable_math
|
|
49
94
|
preprocessor_defs += ' ENRICHED_MARKDOWN_MATH=1'
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
95
|
+
# enable_math already implies ratex_present (the reconciliation above raises on an
|
|
96
|
+
# explicit opt-in with a missing framework and disables the default-on path), so the
|
|
97
|
+
# vendored references below always resolve.
|
|
98
|
+
# Prebuilt static XCFramework (device + simulator[arm64,x86_64] + macOS). Vendored
|
|
99
|
+
# rather than pulled via spm_dependency, which compiled RaTeX's Swift wrapper per
|
|
100
|
+
# requested arch (breaking universal simulator builds, #527) and double-collected
|
|
101
|
+
# its XCFramework signature during archive assembly (#491).
|
|
102
|
+
s.vendored_frameworks = 'ios/vendor/RaTeX.xcframework'
|
|
103
|
+
# RaTeXFontLoader.loadFromCocoaPodsBundle() resolves "RaTeXCoreFonts.bundle" by name,
|
|
104
|
+
# so this resource-bundle name is load-bearing -- keep it exactly RaTeXCoreFonts.
|
|
105
|
+
s.resource_bundles = { 'RaTeXCoreFonts' => ['ios/vendor/Fonts/*.ttf'] }
|
|
55
106
|
end
|
|
56
107
|
|
|
57
108
|
pod_xcconfig = {
|
|
58
|
-
'HEADER_SEARCH_PATHS' =>
|
|
109
|
+
'HEADER_SEARCH_PATHS' => ([
|
|
110
|
+
"\"#{cpp_root}/md4c\"", "\"#{cpp_root}/parser\"", "\"#{cpp_root}/highlight\"",
|
|
111
|
+
"\"$(PODS_TARGET_SRCROOT)/ios/internals\"", "\"$(PODS_TARGET_SRCROOT)/ios/input/internals\""
|
|
112
|
+
] + code_highlight[:header_paths].map { |p| "\"$(PODS_TARGET_SRCROOT)/#{p}\"" }).join(" "),
|
|
59
113
|
'GCC_PREPROCESSOR_DEFINITIONS' => preprocessor_defs,
|
|
60
114
|
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
|
|
61
115
|
'DEFINES_MODULE' => 'YES'
|
|
62
116
|
}
|
|
63
117
|
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
apple_silicon = `sysctl -n hw.optional.arm64 2>/dev/null`.strip == '1'
|
|
67
|
-
|
|
68
|
-
if enable_math && apple_silicon
|
|
69
|
-
# RaTeX's Swift wrapper is compiled from SPM source, so its RaTeX.swiftmodule
|
|
70
|
-
# is emitted only for the arch(es) the build requests. Under ONLY_ACTIVE_ARCH
|
|
71
|
-
# on Apple Silicon that is arm64 only, but universal simulator builds (archive,
|
|
72
|
-
# "Any iOS Simulator Device", Release) also compile this pod for x86_64 and then
|
|
73
|
-
# fail with "could not find module 'RaTeX' for target 'x86_64-apple-ios-simulator'".
|
|
74
|
-
# Excluding x86_64 for the simulator keeps the pod and the app target arch sets in
|
|
75
|
-
# sync. Guarded to Apple Silicon so Intel Macs (which build x86_64 simulator slices)
|
|
76
|
-
# are unaffected; `$(inherited)` preserves exclusions from the user project / other pods.
|
|
77
|
-
pod_xcconfig['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = '$(inherited) x86_64'
|
|
78
|
-
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => '$(inherited) x86_64' }
|
|
79
|
-
end
|
|
80
|
-
|
|
118
|
+
# No EXCLUDED_ARCHS dance: the vendored simulator slice (ios-arm64_x86_64-simulator)
|
|
119
|
+
# already contains x86_64, so universal simulator builds resolve on both arches.
|
|
81
120
|
s.pod_target_xcconfig = pod_xcconfig
|
|
82
121
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
# XCFramework already ships its own definition. Strip the duplicate to
|
|
87
|
-
# prevent "redefinition of module 'RaTeXFFI'" during compilation.
|
|
88
|
-
s.script_phases = [
|
|
89
|
-
{
|
|
90
|
-
name: 'Fix RaTeXFFI Module Redefinition',
|
|
91
|
-
script: <<~'SCRIPT',
|
|
92
|
-
# The shared module.modulemap lives in the platform build-products dir,
|
|
93
|
-
# one level above the per-target BUILT_PRODUCTS_DIR that CocoaPods sets.
|
|
94
|
-
MODULEMAP="${BUILT_PRODUCTS_DIR}/../include/module.modulemap"
|
|
95
|
-
[ -f "$MODULEMAP" ] || exit 0
|
|
96
|
-
sed -i '' -E '/^(framework )?module RaTeXFFI /,/^\}/d' "$MODULEMAP"
|
|
97
|
-
SCRIPT
|
|
98
|
-
execution_position: :before_compile
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: 'Dedupe RaTeX XCFramework Signature',
|
|
102
|
-
script: <<~'SCRIPT',
|
|
103
|
-
# Xcode 26 generates a .signature file for each signed XCFramework.
|
|
104
|
-
# When the RaTeX XCFramework is consumed via spm_dependency inside a
|
|
105
|
-
# CocoaPods target, both the SPM product and the pod target produce a
|
|
106
|
-
# copy. During archive assembly Xcode copies all signatures into a flat
|
|
107
|
-
# Signatures/ directory, and the second copy collides with the first.
|
|
108
|
-
# Removing the pod-target copy prevents the collision. This is a no-op
|
|
109
|
-
# on older Xcode versions or simulator builds where the file is absent.
|
|
110
|
-
rm -f "${CONFIGURATION_BUILD_DIR}/RaTeX.xcframework-ios.signature"
|
|
111
|
-
SCRIPT
|
|
112
|
-
execution_position: :after_compile
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
end
|
|
122
|
+
# No script phases: vendoring a single prebuilt XCFramework means there is no
|
|
123
|
+
# spm_dependency-generated duplicate RaTeXFFI modulemap to strip, and only one
|
|
124
|
+
# signature is collected during archive assembly, so nothing collides.
|
|
116
125
|
|
|
117
126
|
install_modules_dependencies(s)
|
|
118
127
|
end
|
package/android/build.gradle
CHANGED
|
@@ -23,7 +23,128 @@ def getExtOrIntegerDefault(name) {
|
|
|
23
23
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["EnrichedMarkdown_" + name]).toInteger()
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
// The consumer app's package.json "enriched-markdown" block is the build-time source of
|
|
27
|
+
// truth for feature toggles (mirrors the iOS podspecs and react-native-worklets). It is
|
|
28
|
+
// read from the Gradle build root -- "<app>/package.json", one level above the "<app>/android"
|
|
29
|
+
// dir -- so in a monorepo it resolves to the app being built, not the workspace root.
|
|
30
|
+
// Per-app config therefore works; the download side (postinstall) is a separate,
|
|
31
|
+
// install-time decision. Gradle properties remain a deprecated fallback.
|
|
32
|
+
def consumerConfig = [:]
|
|
33
|
+
def consumerAppName = null
|
|
34
|
+
def consumerPackageJson = new File(rootProject.projectDir, "../package.json")
|
|
35
|
+
if (consumerPackageJson.exists()) {
|
|
36
|
+
def parsed = new groovy.json.JsonSlurper().parse(consumerPackageJson)
|
|
37
|
+
if (parsed instanceof Map) {
|
|
38
|
+
if (parsed["enriched-markdown"] instanceof Map) {
|
|
39
|
+
consumerConfig = parsed["enriched-markdown"]
|
|
40
|
+
}
|
|
41
|
+
consumerAppName = parsed["name"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Filesystem-safe per-app slug: package.json "name", else the app directory name -- the
|
|
46
|
+
// same source and fallback the iOS podspec uses (installation root's parent), so both
|
|
47
|
+
// platforms derive an identical slug for the same app. It keys the per-app generated
|
|
48
|
+
// code-highlight registry (generated-<slug>) below so the artifact layout matches iOS and
|
|
49
|
+
// two monorepo apps with different custom language sets never share one dir.
|
|
50
|
+
def consumerAppSlug = (consumerAppName ?: rootProject.projectDir.parentFile?.name ?: "app").toString()
|
|
51
|
+
.replaceAll('[^A-Za-z0-9._-]+', '-').replaceAll('^-+|-+$', '')
|
|
52
|
+
if (!consumerAppSlug) consumerAppSlug = "app"
|
|
53
|
+
|
|
54
|
+
// Math: package.json > gradle property (deprecated) > default true. Android math is a
|
|
55
|
+
// Maven dependency (no downloaded asset), so the flag simply includes or excludes it --
|
|
56
|
+
// there is nothing to be missing, hence no throw as on iOS.
|
|
57
|
+
def mathProp = rootProject.findProperty("enrichedMarkdown.enableMath") ?: findProperty("enrichedMarkdown.enableMath")
|
|
58
|
+
def enableMath
|
|
59
|
+
if (consumerConfig.containsKey("enableMath")) {
|
|
60
|
+
enableMath = consumerConfig.enableMath != false
|
|
61
|
+
if (mathProp != null) {
|
|
62
|
+
logger.warn("[ReactNativeEnrichedMarkdown] DEPRECATED: enrichedMarkdown.enableMath gradle property " +
|
|
63
|
+
"is ignored when \"enriched-markdown\".enableMath is set in your package.json.")
|
|
64
|
+
}
|
|
65
|
+
} else if (mathProp != null) {
|
|
66
|
+
logger.warn("[ReactNativeEnrichedMarkdown] DEPRECATED: enrichedMarkdown.enableMath gradle property " +
|
|
67
|
+
"will be removed in a future version. Configure via \"enriched-markdown\".enableMath in your package.json instead.")
|
|
68
|
+
enableMath = mathProp.toString().toBoolean()
|
|
69
|
+
} else {
|
|
70
|
+
enableMath = true
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Default grammar set derived from the single source of truth,
|
|
74
|
+
// vendor/grammar-versions.json (every grammar with default:true), so the compiled
|
|
75
|
+
// grammars always match the registry gen-registry generates from the same
|
|
76
|
+
// manifest. Resolved in both layouts like gen-registry.mjs below:
|
|
77
|
+
// "../../../vendor" in the monorepo, "../cpp/highlight" when published.
|
|
78
|
+
def grammarManifest = [
|
|
79
|
+
new File(projectDir, "../../../vendor/grammar-versions.json"),
|
|
80
|
+
new File(projectDir, "../cpp/highlight/grammar-versions.json"),
|
|
81
|
+
].find { it.exists() }
|
|
82
|
+
if (grammarManifest == null) {
|
|
83
|
+
throw new GradleException("[code-highlight] grammar-versions.json not found; cannot resolve the default language set. Build from the monorepo or a published tarball.")
|
|
84
|
+
}
|
|
85
|
+
def defaultCodeHighlightLanguages = new groovy.json.JsonSlurper().parse(grammarManifest)
|
|
86
|
+
.grammars.findAll { id, spec -> spec['default'] }.collect { id, spec -> id }
|
|
87
|
+
// Code highlight enable: package.json > gradle property (deprecated) > default on.
|
|
88
|
+
// `codeHighlightExplicit` tracks an active opt-in (vs the implicit default), which
|
|
89
|
+
// decides the missing-grammars behavior below.
|
|
90
|
+
def codeHighlightProp = rootProject.findProperty("enrichedMarkdown.enableCodeHighlight") ?: findProperty("enrichedMarkdown.enableCodeHighlight")
|
|
91
|
+
def codeHighlightStamp = new File(projectDir, "../cpp/highlight/vendor/grammars/.stamp")
|
|
92
|
+
def codeHighlightRequested
|
|
93
|
+
def codeHighlightExplicit
|
|
94
|
+
if (consumerConfig.containsKey("enableCodeHighlight")) {
|
|
95
|
+
codeHighlightRequested = consumerConfig.enableCodeHighlight != false
|
|
96
|
+
codeHighlightExplicit = codeHighlightRequested
|
|
97
|
+
if (codeHighlightProp != null) {
|
|
98
|
+
logger.warn("[ReactNativeEnrichedMarkdown] DEPRECATED: enrichedMarkdown.enableCodeHighlight gradle property " +
|
|
99
|
+
"is ignored when \"enriched-markdown\".enableCodeHighlight is set in your package.json.")
|
|
100
|
+
}
|
|
101
|
+
} else if (codeHighlightProp != null) {
|
|
102
|
+
logger.warn("[ReactNativeEnrichedMarkdown] DEPRECATED: enrichedMarkdown.enableCodeHighlight gradle property " +
|
|
103
|
+
"will be removed in a future version. Configure via \"enriched-markdown\".enableCodeHighlight in your package.json instead.")
|
|
104
|
+
codeHighlightRequested = codeHighlightProp.toString().toBoolean()
|
|
105
|
+
codeHighlightExplicit = codeHighlightRequested
|
|
106
|
+
} else {
|
|
107
|
+
codeHighlightRequested = true
|
|
108
|
+
codeHighlightExplicit = false
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// The grammars/.stamp marker is written only after every grammar source is fully vendored
|
|
112
|
+
// at postinstall. An explicit opt-in with the grammars missing fails loud with the fix; on
|
|
113
|
+
// by default but missing (a partial/failed download, or a monorepo root opt-out) falls back
|
|
114
|
+
// to a clean no-op build. Gating on the stamp also keeps CMake from being fed missing sources.
|
|
115
|
+
def enableCodeHighlight
|
|
116
|
+
if (!codeHighlightRequested) {
|
|
117
|
+
enableCodeHighlight = false
|
|
118
|
+
} else if (codeHighlightStamp.exists()) {
|
|
119
|
+
enableCodeHighlight = true
|
|
120
|
+
} else if (codeHighlightExplicit) {
|
|
121
|
+
throw new GradleException("[ReactNativeEnrichedMarkdown] code highlighting is enabled but the tree-sitter " +
|
|
122
|
+
"grammars are not installed. Reinstall to fetch them: `npm rebuild react-native-enriched-markdown-scaffold`. " +
|
|
123
|
+
"To disable, set \"enriched-markdown\".enableCodeHighlight = false in your app package.json. " +
|
|
124
|
+
"Troubleshooting: https://github.com/software-mansion/enriched-markdown/blob/main/docs/NATIVE_ASSETS.md")
|
|
125
|
+
} else {
|
|
126
|
+
enableCodeHighlight = false
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Languages: package.json > gradle property (deprecated) > manifest defaults. An explicit
|
|
130
|
+
// empty array disables all languages (codeHighlightActive below); only the default/property
|
|
131
|
+
// paths fall back to the manifest set.
|
|
132
|
+
def codeHighlightLanguagesProp = rootProject.findProperty("enrichedMarkdown.codeHighlightLanguages") ?: findProperty("enrichedMarkdown.codeHighlightLanguages")
|
|
133
|
+
def codeHighlightLanguages
|
|
134
|
+
if (consumerConfig.get("codeHighlightLanguages") instanceof List) {
|
|
135
|
+
codeHighlightLanguages = consumerConfig.codeHighlightLanguages.collect { it.toString().trim() }.findAll { it }
|
|
136
|
+
if (codeHighlightLanguagesProp != null) {
|
|
137
|
+
logger.warn("[ReactNativeEnrichedMarkdown] DEPRECATED: enrichedMarkdown.codeHighlightLanguages gradle property " +
|
|
138
|
+
"is ignored when \"enriched-markdown\".codeHighlightLanguages is set in your package.json.")
|
|
139
|
+
}
|
|
140
|
+
} else if (codeHighlightLanguagesProp) {
|
|
141
|
+
logger.warn("[ReactNativeEnrichedMarkdown] DEPRECATED: enrichedMarkdown.codeHighlightLanguages gradle property " +
|
|
142
|
+
"will be removed in a future version. Configure via \"enriched-markdown\".codeHighlightLanguages in your package.json instead.")
|
|
143
|
+
codeHighlightLanguages = codeHighlightLanguagesProp.toString().split(",").collect { it.trim() }.findAll { it }
|
|
144
|
+
} else {
|
|
145
|
+
codeHighlightLanguages = defaultCodeHighlightLanguages
|
|
146
|
+
}
|
|
147
|
+
def codeHighlightActive = enableCodeHighlight && !codeHighlightLanguages.isEmpty()
|
|
27
148
|
|
|
28
149
|
android {
|
|
29
150
|
namespace "com.swmansion.enriched.markdown"
|
|
@@ -35,6 +156,7 @@ android {
|
|
|
35
156
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
36
157
|
consumerProguardFiles "consumer-rules.pro"
|
|
37
158
|
buildConfigField "boolean", "ENABLE_MATH", "${enableMath}"
|
|
159
|
+
buildConfigField "boolean", "ENABLE_CODE_HIGHLIGHT", "${codeHighlightActive}"
|
|
38
160
|
}
|
|
39
161
|
|
|
40
162
|
buildFeatures {
|
|
@@ -56,6 +178,17 @@ android {
|
|
|
56
178
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
57
179
|
}
|
|
58
180
|
|
|
181
|
+
// JVM unit tests for the pure-Kotlin editor logic (serialization, range math).
|
|
182
|
+
// returnDefaultValues makes the android.jar stubs no-ops instead of throwing, so a
|
|
183
|
+
// class that only logs (MarkdownSerializer -> android.util.Log) is testable without
|
|
184
|
+
// pulling in Robolectric. Anything needing real Android behaviour belongs in the
|
|
185
|
+
// instrumented/Robolectric suite in packages/android-enriched-markdown/ui instead.
|
|
186
|
+
testOptions {
|
|
187
|
+
unitTests {
|
|
188
|
+
returnDefaultValues = true
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
59
192
|
sourceSets {
|
|
60
193
|
main {
|
|
61
194
|
java.srcDirs += [
|
|
@@ -67,6 +200,62 @@ android {
|
|
|
67
200
|
}
|
|
68
201
|
}
|
|
69
202
|
}
|
|
203
|
+
|
|
204
|
+
testOptions {
|
|
205
|
+
unitTests.includeAndroidResources = true
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Code-block syntax highlighting (tree-sitter) native wiring. This module owns
|
|
210
|
+
// no externalNativeBuild block: RN autolinking compiles src/main/jni/CMakeLists.txt
|
|
211
|
+
// as part of the consumer app's native build, so the app -- not this library --
|
|
212
|
+
// owns the CMake arguments. The enable flag + selected grammars therefore reach
|
|
213
|
+
// CMake through a config file written here during configuration (before any
|
|
214
|
+
// native build task runs) and include()d by CMakeLists.txt.
|
|
215
|
+
def highlightConfigDir = new File(projectDir, "build/generated/highlight")
|
|
216
|
+
highlightConfigDir.mkdirs()
|
|
217
|
+
def highlightConfigFile = new File(highlightConfigDir, "highlight-config.cmake")
|
|
218
|
+
if (codeHighlightActive) {
|
|
219
|
+
def vendorDir = new File(projectDir, "../cpp/highlight/vendor").canonicalPath
|
|
220
|
+
def committedGenerated = new File(vendorDir, "generated")
|
|
221
|
+
def generatedDir
|
|
222
|
+
if (codeHighlightLanguages.toSorted() == defaultCodeHighlightLanguages.toSorted() && committedGenerated.exists()) {
|
|
223
|
+
// Common case: the committed default-set registry ships in-tree, no codegen.
|
|
224
|
+
generatedDir = committedGenerated
|
|
225
|
+
} else {
|
|
226
|
+
// Custom language set: regenerate the registry from the vendored .scm files into a
|
|
227
|
+
// per-app dir (generated-<slug>), mirroring iOS. Android rewrites this on every
|
|
228
|
+
// gradle configure so it never had iOS's persistent clash, but keying per app keeps
|
|
229
|
+
// the two platforms' artifact layout identical. (highlight-config.cmake itself stays
|
|
230
|
+
// at the CMakeLists-fixed shared path and is rewritten each configure.)
|
|
231
|
+
generatedDir = new File(highlightConfigDir, "generated-${consumerAppSlug}")
|
|
232
|
+
generatedDir.mkdirs()
|
|
233
|
+
def genScript = [
|
|
234
|
+
new File(projectDir, "../../../vendor/gen-registry.mjs"),
|
|
235
|
+
new File(projectDir, "../cpp/highlight/gen-registry.mjs"),
|
|
236
|
+
].find { it.exists() }
|
|
237
|
+
if (genScript == null) {
|
|
238
|
+
throw new GradleException("enrichedMarkdown.codeHighlightLanguages is customized but vendor/gen-registry.mjs was not found. Use the default language set or build from the monorepo.")
|
|
239
|
+
}
|
|
240
|
+
// Run node directly via ProcessBuilder rather than Project.exec {}, which was
|
|
241
|
+
// removed in Gradle 9. Runs at configuration time (before the native build),
|
|
242
|
+
// and surfaces gen-registry's own stderr on failure.
|
|
243
|
+
def genCmd = ["node", genScript.canonicalPath, "--vendor-dir", vendorDir,
|
|
244
|
+
"--languages", codeHighlightLanguages.join(","), "--out", generatedDir.canonicalPath]
|
|
245
|
+
def genProc = new ProcessBuilder(genCmd).redirectErrorStream(true).start()
|
|
246
|
+
def genOut = genProc.inputStream.text
|
|
247
|
+
def genExit = genProc.waitFor()
|
|
248
|
+
if (genExit != 0) {
|
|
249
|
+
throw new GradleException("[code-highlight] gen-registry.mjs failed (exit ${genExit}):\n${genOut}")
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
highlightConfigFile.text = """\
|
|
253
|
+
set(ENRICHED_MARKDOWN_CODE_HIGHLIGHT ON)
|
|
254
|
+
set(ENRICHED_MARKDOWN_HIGHLIGHT_LANGUAGES "${codeHighlightLanguages.join(';')}")
|
|
255
|
+
set(ENRICHED_MARKDOWN_HIGHLIGHT_GENERATED_DIR "${generatedDir.canonicalPath.replace('\\', '/')}")
|
|
256
|
+
"""
|
|
257
|
+
} else {
|
|
258
|
+
highlightConfigFile.text = "set(ENRICHED_MARKDOWN_CODE_HIGHLIGHT OFF)\n"
|
|
70
259
|
}
|
|
71
260
|
|
|
72
261
|
repositories {
|
|
@@ -85,6 +274,7 @@ dependencies {
|
|
|
85
274
|
if (enableMath) {
|
|
86
275
|
implementation("io.github.erweixin:ratex-android:0.1.10")
|
|
87
276
|
}
|
|
277
|
+
testImplementation "junit:junit:4.13.2"
|
|
88
278
|
}
|
|
89
279
|
|
|
90
280
|
react {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ProGuard/R8 consumer rules for react-native-enriched-markdown
|
|
1
|
+
# ProGuard/R8 consumer rules for react-native-enriched-markdown-scaffold
|
|
2
2
|
#
|
|
3
3
|
# JNI: Classes accessed from C++ (jni-adapter.cpp) via FindClass/GetFieldID.
|
|
4
4
|
# R8 cannot trace hardcoded string lookups in native code.
|
package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java
CHANGED
|
@@ -32,6 +32,9 @@ public class EnrichedMarkdownManagerDelegate<T extends View, U extends BaseViewM
|
|
|
32
32
|
case "markdownStyle":
|
|
33
33
|
mViewManager.setMarkdownStyle(view, (ReadableMap) value);
|
|
34
34
|
break;
|
|
35
|
+
case "enableTaskListItemToggle":
|
|
36
|
+
mViewManager.setEnableTaskListItemToggle(view, value == null ? true : (boolean) value);
|
|
37
|
+
break;
|
|
35
38
|
case "enableLinkPreview":
|
|
36
39
|
mViewManager.setEnableLinkPreview(view, value == null ? true : (boolean) value);
|
|
37
40
|
break;
|
|
@@ -65,9 +68,15 @@ public class EnrichedMarkdownManagerDelegate<T extends View, U extends BaseViewM
|
|
|
65
68
|
case "spoilerOverlay":
|
|
66
69
|
mViewManager.setSpoilerOverlay(view, value == null ? "particles" : (String) value);
|
|
67
70
|
break;
|
|
71
|
+
case "contextMenuHidden":
|
|
72
|
+
mViewManager.setContextMenuHidden(view, value == null ? false : (boolean) value);
|
|
73
|
+
break;
|
|
68
74
|
case "contextMenuItems":
|
|
69
75
|
mViewManager.setContextMenuItems(view, (ReadableArray) value);
|
|
70
76
|
break;
|
|
77
|
+
case "imageRequestHeaders":
|
|
78
|
+
mViewManager.setImageRequestHeaders(view, (ReadableArray) value);
|
|
79
|
+
break;
|
|
71
80
|
case "selectionMenuConfig":
|
|
72
81
|
mViewManager.setSelectionMenuConfig(view, (ReadableMap) value);
|
|
73
82
|
break;
|
package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java
CHANGED
|
@@ -18,6 +18,7 @@ import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
|
|
|
18
18
|
public interface EnrichedMarkdownManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
|
|
19
19
|
void setMarkdown(T view, @Nullable String value);
|
|
20
20
|
void setMarkdownStyle(T view, @Nullable ReadableMap value);
|
|
21
|
+
void setEnableTaskListItemToggle(T view, boolean value);
|
|
21
22
|
void setEnableLinkPreview(T view, boolean value);
|
|
22
23
|
void setSelectable(T view, boolean value);
|
|
23
24
|
void setSelectionColor(T view, @Nullable Integer value);
|
|
@@ -29,7 +30,9 @@ public interface EnrichedMarkdownManagerInterface<T extends View> extends ViewMa
|
|
|
29
30
|
void setStreamingAnimation(T view, boolean value);
|
|
30
31
|
void setStreamingConfig(T view, @Nullable ReadableMap value);
|
|
31
32
|
void setSpoilerOverlay(T view, @Nullable String value);
|
|
33
|
+
void setContextMenuHidden(T view, boolean value);
|
|
32
34
|
void setContextMenuItems(T view, @Nullable ReadableArray value);
|
|
35
|
+
void setImageRequestHeaders(T view, @Nullable ReadableArray value);
|
|
33
36
|
void setSelectionMenuConfig(T view, @Nullable ReadableMap value);
|
|
34
37
|
void setAccessibilityLabels(T view, @Nullable ReadableMap value);
|
|
35
38
|
void setTextBreakStrategy(T view, @Nullable String value);
|
|
@@ -44,9 +44,15 @@ public class EnrichedMarkdownTextInputManagerDelegate<T extends View, U extends
|
|
|
44
44
|
case "scrollEnabled":
|
|
45
45
|
mViewManager.setScrollEnabled(view, value == null ? false : (boolean) value);
|
|
46
46
|
break;
|
|
47
|
+
case "blockSyntax":
|
|
48
|
+
mViewManager.setBlockSyntax(view, value == null ? false : (boolean) value);
|
|
49
|
+
break;
|
|
47
50
|
case "autoCapitalize":
|
|
48
51
|
mViewManager.setAutoCapitalize(view, value == null ? null : (String) value);
|
|
49
52
|
break;
|
|
53
|
+
case "interceptPaste":
|
|
54
|
+
mViewManager.setInterceptPaste(view, value == null ? false : (boolean) value);
|
|
55
|
+
break;
|
|
50
56
|
case "multiline":
|
|
51
57
|
mViewManager.setMultiline(view, value == null ? false : (boolean) value);
|
|
52
58
|
break;
|
|
@@ -130,12 +136,30 @@ public class EnrichedMarkdownTextInputManagerDelegate<T extends View, U extends
|
|
|
130
136
|
case "toggleSpoiler":
|
|
131
137
|
mViewManager.toggleSpoiler(view);
|
|
132
138
|
break;
|
|
139
|
+
case "toggleHeading":
|
|
140
|
+
mViewManager.toggleHeading(view, args.getInt(0));
|
|
141
|
+
break;
|
|
142
|
+
case "toggleUnorderedList":
|
|
143
|
+
mViewManager.toggleUnorderedList(view);
|
|
144
|
+
break;
|
|
145
|
+
case "toggleOrderedList":
|
|
146
|
+
mViewManager.toggleOrderedList(view);
|
|
147
|
+
break;
|
|
148
|
+
case "indentList":
|
|
149
|
+
mViewManager.indentList(view);
|
|
150
|
+
break;
|
|
151
|
+
case "outdentList":
|
|
152
|
+
mViewManager.outdentList(view);
|
|
153
|
+
break;
|
|
133
154
|
case "setLink":
|
|
134
155
|
mViewManager.setLink(view, args.getString(0));
|
|
135
156
|
break;
|
|
136
157
|
case "insertLink":
|
|
137
158
|
mViewManager.insertLink(view, args.getString(0), args.getString(1));
|
|
138
159
|
break;
|
|
160
|
+
case "insertText":
|
|
161
|
+
mViewManager.insertText(view, args.getString(0));
|
|
162
|
+
break;
|
|
139
163
|
case "insertMention":
|
|
140
164
|
mViewManager.insertMention(view, args.getString(0), args.getString(1));
|
|
141
165
|
break;
|
|
@@ -157,6 +181,9 @@ public class EnrichedMarkdownTextInputManagerDelegate<T extends View, U extends
|
|
|
157
181
|
case "copyToClipboard":
|
|
158
182
|
mViewManager.copyToClipboard(view);
|
|
159
183
|
break;
|
|
184
|
+
case "resolvePaste":
|
|
185
|
+
mViewManager.resolvePaste(view, args.getString(0), args.getString(1));
|
|
186
|
+
break;
|
|
160
187
|
case "requestMarkdown":
|
|
161
188
|
mViewManager.requestMarkdown(view, args.getInt(0));
|
|
162
189
|
break;
|
|
@@ -22,7 +22,9 @@ public interface EnrichedMarkdownTextInputManagerInterface<T extends View> exten
|
|
|
22
22
|
void setEditable(T view, boolean value);
|
|
23
23
|
void setAutoFocus(T view, boolean value);
|
|
24
24
|
void setScrollEnabled(T view, boolean value);
|
|
25
|
+
void setBlockSyntax(T view, boolean value);
|
|
25
26
|
void setAutoCapitalize(T view, @Nullable String value);
|
|
27
|
+
void setInterceptPaste(T view, boolean value);
|
|
26
28
|
void setMultiline(T view, boolean value);
|
|
27
29
|
void setCursorColor(T view, @Nullable Integer value);
|
|
28
30
|
void setSelectionColor(T view, @Nullable Integer value);
|
|
@@ -48,8 +50,14 @@ public interface EnrichedMarkdownTextInputManagerInterface<T extends View> exten
|
|
|
48
50
|
void toggleUnderline(T view);
|
|
49
51
|
void toggleStrikethrough(T view);
|
|
50
52
|
void toggleSpoiler(T view);
|
|
53
|
+
void toggleHeading(T view, int level);
|
|
54
|
+
void toggleUnorderedList(T view);
|
|
55
|
+
void toggleOrderedList(T view);
|
|
56
|
+
void indentList(T view);
|
|
57
|
+
void outdentList(T view);
|
|
51
58
|
void setLink(T view, String url);
|
|
52
59
|
void insertLink(T view, String text, String url);
|
|
60
|
+
void insertText(T view, String text);
|
|
53
61
|
void insertMention(T view, String displayText, String url);
|
|
54
62
|
void startMention(T view, String indicator);
|
|
55
63
|
void removeLink(T view);
|
|
@@ -57,6 +65,7 @@ public interface EnrichedMarkdownTextInputManagerInterface<T extends View> exten
|
|
|
57
65
|
void updateMath(T view, int start, String latex, boolean displayMode);
|
|
58
66
|
void removeMath(T view, int start);
|
|
59
67
|
void copyToClipboard(T view);
|
|
68
|
+
void resolvePaste(T view, String text, String markdown);
|
|
60
69
|
void requestMarkdown(T view, int requestId);
|
|
61
70
|
void requestCaretRect(T view, int requestId);
|
|
62
71
|
}
|