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
|
@@ -7,6 +7,10 @@ import type {
|
|
|
7
7
|
} from './types/MarkdownStyleInternal';
|
|
8
8
|
import { isStyleEqual, mergeSubStyle } from './styleUtils';
|
|
9
9
|
import { normalizeLinkVariantEntries } from './linkVariantUtils';
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_HEADING_FONT_WEIGHT,
|
|
12
|
+
HEADING_DEFAULTS,
|
|
13
|
+
} from './headingDefaults';
|
|
10
14
|
|
|
11
15
|
const SYSTEM_FONT =
|
|
12
16
|
'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
@@ -14,7 +18,6 @@ const MONOSPACE_FONT =
|
|
|
14
18
|
'ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace';
|
|
15
19
|
|
|
16
20
|
const defaultTextColor = '#1F2937';
|
|
17
|
-
const defaultHeadingColor = '#111827';
|
|
18
21
|
|
|
19
22
|
const baseHeader: {
|
|
20
23
|
fontFamily: string;
|
|
@@ -24,7 +27,7 @@ const baseHeader: {
|
|
|
24
27
|
textAlign: BlockTextAlign;
|
|
25
28
|
} = {
|
|
26
29
|
fontFamily: SYSTEM_FONT,
|
|
27
|
-
fontWeight:
|
|
30
|
+
fontWeight: DEFAULT_HEADING_FONT_WEIGHT,
|
|
28
31
|
marginTop: 0,
|
|
29
32
|
marginBottom: 8,
|
|
30
33
|
textAlign: 'auto',
|
|
@@ -43,38 +46,38 @@ const DEFAULT_NORMALIZED_STYLE: MarkdownStyleInternal = Object.freeze({
|
|
|
43
46
|
},
|
|
44
47
|
h1: {
|
|
45
48
|
...baseHeader,
|
|
46
|
-
fontSize:
|
|
47
|
-
color:
|
|
49
|
+
fontSize: HEADING_DEFAULTS.h1.fontSize,
|
|
50
|
+
color: HEADING_DEFAULTS.h1.color,
|
|
48
51
|
lineHeight: 38,
|
|
49
52
|
},
|
|
50
53
|
h2: {
|
|
51
54
|
...baseHeader,
|
|
52
|
-
fontSize:
|
|
53
|
-
color:
|
|
55
|
+
fontSize: HEADING_DEFAULTS.h2.fontSize,
|
|
56
|
+
color: HEADING_DEFAULTS.h2.color,
|
|
54
57
|
lineHeight: 32,
|
|
55
58
|
},
|
|
56
59
|
h3: {
|
|
57
60
|
...baseHeader,
|
|
58
|
-
fontSize:
|
|
59
|
-
color:
|
|
61
|
+
fontSize: HEADING_DEFAULTS.h3.fontSize,
|
|
62
|
+
color: HEADING_DEFAULTS.h3.color,
|
|
60
63
|
lineHeight: 28,
|
|
61
64
|
},
|
|
62
65
|
h4: {
|
|
63
66
|
...baseHeader,
|
|
64
|
-
fontSize:
|
|
65
|
-
color:
|
|
67
|
+
fontSize: HEADING_DEFAULTS.h4.fontSize,
|
|
68
|
+
color: HEADING_DEFAULTS.h4.color,
|
|
66
69
|
lineHeight: 26,
|
|
67
70
|
},
|
|
68
71
|
h5: {
|
|
69
72
|
...baseHeader,
|
|
70
|
-
fontSize:
|
|
71
|
-
color:
|
|
73
|
+
fontSize: HEADING_DEFAULTS.h5.fontSize,
|
|
74
|
+
color: HEADING_DEFAULTS.h5.color,
|
|
72
75
|
lineHeight: 24,
|
|
73
76
|
},
|
|
74
77
|
h6: {
|
|
75
78
|
...baseHeader,
|
|
76
|
-
fontSize:
|
|
77
|
-
color:
|
|
79
|
+
fontSize: HEADING_DEFAULTS.h6.fontSize,
|
|
80
|
+
color: HEADING_DEFAULTS.h6.color,
|
|
78
81
|
lineHeight: 22,
|
|
79
82
|
},
|
|
80
83
|
blockquote: {
|
|
@@ -89,6 +92,8 @@ const DEFAULT_NORMALIZED_STYLE: MarkdownStyleInternal = Object.freeze({
|
|
|
89
92
|
borderWidth: 3,
|
|
90
93
|
gapWidth: 16,
|
|
91
94
|
backgroundColor: '#F9FAFB',
|
|
95
|
+
borderRadius: 0,
|
|
96
|
+
padding: 0,
|
|
92
97
|
},
|
|
93
98
|
list: {
|
|
94
99
|
fontSize: 16,
|
|
@@ -105,6 +110,7 @@ const DEFAULT_NORMALIZED_STYLE: MarkdownStyleInternal = Object.freeze({
|
|
|
105
110
|
markerFontWeight: '500',
|
|
106
111
|
gapWidth: 12,
|
|
107
112
|
marginLeft: 24,
|
|
113
|
+
itemSpacing: 0,
|
|
108
114
|
},
|
|
109
115
|
codeBlock: {
|
|
110
116
|
fontSize: 14,
|
|
@@ -119,6 +125,22 @@ const DEFAULT_NORMALIZED_STYLE: MarkdownStyleInternal = Object.freeze({
|
|
|
119
125
|
borderRadius: 8,
|
|
120
126
|
borderWidth: 1,
|
|
121
127
|
padding: 16,
|
|
128
|
+
syntaxColors: {
|
|
129
|
+
keyword: '#FF7B72',
|
|
130
|
+
operatorColor: '#F3F4F6',
|
|
131
|
+
punctuation: '#F3F4F6',
|
|
132
|
+
string: '#A5D6FF',
|
|
133
|
+
number: '#79C0FF',
|
|
134
|
+
constant: '#79C0FF',
|
|
135
|
+
comment: '#8B949E',
|
|
136
|
+
function: '#D2A8FF',
|
|
137
|
+
type: '#FFA657',
|
|
138
|
+
variable: '#F3F4F6',
|
|
139
|
+
property: '#79C0FF',
|
|
140
|
+
tag: '#7EE787',
|
|
141
|
+
attribute: '#79C0FF',
|
|
142
|
+
embedded: '#F3F4F6',
|
|
143
|
+
},
|
|
122
144
|
},
|
|
123
145
|
link: {
|
|
124
146
|
fontFamily: '',
|
|
@@ -142,7 +164,15 @@ const DEFAULT_NORMALIZED_STYLE: MarkdownStyleInternal = Object.freeze({
|
|
|
142
164
|
backgroundColor: '#FDF2F4',
|
|
143
165
|
borderColor: '#F8D7DA',
|
|
144
166
|
},
|
|
145
|
-
image: {
|
|
167
|
+
image: {
|
|
168
|
+
height: 200,
|
|
169
|
+
maxHeight: 0,
|
|
170
|
+
aspectRatio: 0,
|
|
171
|
+
resizeMode: '' as const,
|
|
172
|
+
borderRadius: 8,
|
|
173
|
+
marginTop: 0,
|
|
174
|
+
marginBottom: 16,
|
|
175
|
+
},
|
|
146
176
|
inlineImage: { size: 20 },
|
|
147
177
|
thematicBreak: {
|
|
148
178
|
color: '#E5E7EB',
|
|
@@ -168,6 +198,8 @@ const DEFAULT_NORMALIZED_STYLE: MarkdownStyleInternal = Object.freeze({
|
|
|
168
198
|
borderRadius: 6,
|
|
169
199
|
cellPaddingHorizontal: 12,
|
|
170
200
|
cellPaddingVertical: 8,
|
|
201
|
+
horizontalOverflow: 0,
|
|
202
|
+
align: '' as const,
|
|
171
203
|
},
|
|
172
204
|
math: {
|
|
173
205
|
fontSize: 20,
|
|
@@ -269,6 +301,12 @@ export const normalizeMarkdownStyle = (
|
|
|
269
301
|
);
|
|
270
302
|
}
|
|
271
303
|
|
|
304
|
+
// maxHeight/aspectRatio sizing is resize-mode driven; default to 'cover'.
|
|
305
|
+
const image = result.image as MarkdownStyleInternal['image'];
|
|
306
|
+
if (!image.resizeMode && (image.maxHeight > 0 || image.aspectRatio > 0)) {
|
|
307
|
+
(result.image as { resizeMode: string }).resizeMode = 'cover';
|
|
308
|
+
}
|
|
309
|
+
|
|
272
310
|
if (!style.highlight?.color) {
|
|
273
311
|
const paragraphColor = (
|
|
274
312
|
result.paragraph as MarkdownStyleInternal['paragraph']
|
|
@@ -277,6 +315,16 @@ export const normalizeMarkdownStyle = (
|
|
|
277
315
|
paragraphColor;
|
|
278
316
|
}
|
|
279
317
|
|
|
318
|
+
// The public API exposes `operator`, but the internal token is `operatorColor`
|
|
319
|
+
// (`operator` is reserved in the generated C++ struct). Remap it after merge.
|
|
320
|
+
const syntaxColors = (
|
|
321
|
+
result.codeBlock as { syntaxColors?: Record<string, unknown> }
|
|
322
|
+
).syntaxColors;
|
|
323
|
+
if (syntaxColors && 'operator' in syntaxColors) {
|
|
324
|
+
syntaxColors.operatorColor = syntaxColors.operator;
|
|
325
|
+
delete syntaxColors.operator;
|
|
326
|
+
}
|
|
327
|
+
|
|
280
328
|
const finalResult = Object.freeze(result) as unknown as MarkdownStyleInternal;
|
|
281
329
|
refCache.set(style, finalResult);
|
|
282
330
|
structuralCache.unshift({ style, result: finalResult });
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { processColor, type ColorValue } from 'react-native';
|
|
2
2
|
import type {
|
|
3
|
+
HeadingStyle,
|
|
3
4
|
LinkStyle,
|
|
4
5
|
MarkdownTextInputStyle,
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
InputInlineMathStyle,
|
|
7
|
+
InputMathStyle,
|
|
7
8
|
} from './EnrichedMarkdownTextInput';
|
|
8
9
|
import { normalizeLinkVariantEntries } from './linkVariantUtils';
|
|
9
10
|
import { normalizeColor } from './styleUtils';
|
|
11
|
+
import {
|
|
12
|
+
DEFAULT_HEADING_FONT_WEIGHT,
|
|
13
|
+
HEADING_DEFAULTS,
|
|
14
|
+
type HeadingLevelKey,
|
|
15
|
+
} from './headingDefaults';
|
|
10
16
|
|
|
11
17
|
interface LinkVariantEntryInternal {
|
|
12
18
|
pattern: string;
|
|
@@ -15,7 +21,7 @@ interface LinkVariantEntryInternal {
|
|
|
15
21
|
backgroundColor: ColorValue;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
|
-
interface
|
|
24
|
+
interface InputInlineMathStyleInternal {
|
|
19
25
|
color: ColorValue;
|
|
20
26
|
fontSize: number;
|
|
21
27
|
backgroundColor: ColorValue;
|
|
@@ -29,10 +35,16 @@ interface MathStyleInternal {
|
|
|
29
35
|
fontWeight: string;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
interface
|
|
38
|
+
interface InputMathStyleInternal extends InputInlineMathStyleInternal {
|
|
33
39
|
marginTop: number;
|
|
34
40
|
marginBottom: number;
|
|
35
|
-
|
|
41
|
+
textAlign: 'left' | 'center' | 'right';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface HeadingStyleInternal {
|
|
45
|
+
fontSize: number;
|
|
46
|
+
fontWeight: string;
|
|
47
|
+
color: ColorValue;
|
|
36
48
|
}
|
|
37
49
|
|
|
38
50
|
interface MarkdownTextInputStyleInternal {
|
|
@@ -52,8 +64,17 @@ interface MarkdownTextInputStyleInternal {
|
|
|
52
64
|
color: ColorValue;
|
|
53
65
|
backgroundColor: ColorValue;
|
|
54
66
|
};
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
inlineMath: InputInlineMathStyleInternal;
|
|
68
|
+
math: InputMathStyleInternal;
|
|
69
|
+
h1: HeadingStyleInternal;
|
|
70
|
+
h2: HeadingStyleInternal;
|
|
71
|
+
h3: HeadingStyleInternal;
|
|
72
|
+
h4: HeadingStyleInternal;
|
|
73
|
+
h5: HeadingStyleInternal;
|
|
74
|
+
h6: HeadingStyleInternal;
|
|
75
|
+
list: {
|
|
76
|
+
itemSpacing: number;
|
|
77
|
+
};
|
|
57
78
|
}
|
|
58
79
|
|
|
59
80
|
const DEFAULT_LINK_COLOR = '#2563EB';
|
|
@@ -66,7 +87,7 @@ const DEFAULT_MATH_BORDER_COLOR = 'transparent';
|
|
|
66
87
|
|
|
67
88
|
const TRANSPARENT = processColor('transparent')!;
|
|
68
89
|
|
|
69
|
-
const
|
|
90
|
+
const defaultInlineMathInternal: InputInlineMathStyleInternal = Object.freeze({
|
|
70
91
|
color: processColor(DEFAULT_MATH_COLOR)!,
|
|
71
92
|
fontSize: 16,
|
|
72
93
|
backgroundColor: processColor(DEFAULT_MATH_BG_COLOR)!,
|
|
@@ -80,7 +101,7 @@ const defaultMathInternal: MathStyleInternal = Object.freeze({
|
|
|
80
101
|
fontWeight: 'normal',
|
|
81
102
|
});
|
|
82
103
|
|
|
83
|
-
const
|
|
104
|
+
const defaultBlockMathInternal: InputMathStyleInternal = Object.freeze({
|
|
84
105
|
color: processColor(DEFAULT_MATH_COLOR)!,
|
|
85
106
|
fontSize: 20,
|
|
86
107
|
backgroundColor: processColor(DEFAULT_MATH_BG_COLOR)!,
|
|
@@ -94,9 +115,20 @@ const defaultMathBlockInternal: MathBlockStyleInternal = Object.freeze({
|
|
|
94
115
|
fontWeight: 'normal',
|
|
95
116
|
marginTop: 8,
|
|
96
117
|
marginBottom: 8,
|
|
97
|
-
|
|
118
|
+
textAlign: 'center',
|
|
98
119
|
});
|
|
99
120
|
|
|
121
|
+
// Defaults shared with the read-only renderer via headingDefaults; consumers
|
|
122
|
+
// override per level via markdownStyle h1..h6.
|
|
123
|
+
const defaultHeadingInternal = (key: HeadingLevelKey): HeadingStyleInternal => {
|
|
124
|
+
const d = HEADING_DEFAULTS[key];
|
|
125
|
+
return {
|
|
126
|
+
fontSize: d.fontSize,
|
|
127
|
+
fontWeight: DEFAULT_HEADING_FONT_WEIGHT,
|
|
128
|
+
color: processColor(d.color)!,
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
|
|
100
132
|
const defaultInternal: MarkdownTextInputStyleInternal = Object.freeze({
|
|
101
133
|
strong: {
|
|
102
134
|
color: undefined,
|
|
@@ -114,10 +146,31 @@ const defaultInternal: MarkdownTextInputStyleInternal = Object.freeze({
|
|
|
114
146
|
color: processColor(DEFAULT_SPOILER_COLOR)!,
|
|
115
147
|
backgroundColor: processColor(DEFAULT_SPOILER_BG_COLOR)!,
|
|
116
148
|
},
|
|
117
|
-
|
|
118
|
-
|
|
149
|
+
inlineMath: defaultInlineMathInternal,
|
|
150
|
+
math: defaultBlockMathInternal,
|
|
151
|
+
h1: defaultHeadingInternal('h1'),
|
|
152
|
+
h2: defaultHeadingInternal('h2'),
|
|
153
|
+
h3: defaultHeadingInternal('h3'),
|
|
154
|
+
h4: defaultHeadingInternal('h4'),
|
|
155
|
+
h5: defaultHeadingInternal('h5'),
|
|
156
|
+
h6: defaultHeadingInternal('h6'),
|
|
157
|
+
list: {
|
|
158
|
+
itemSpacing: 0,
|
|
159
|
+
},
|
|
119
160
|
});
|
|
120
161
|
|
|
162
|
+
const normalizeHeadingStyle = (
|
|
163
|
+
key: HeadingLevelKey,
|
|
164
|
+
style: HeadingStyle | undefined
|
|
165
|
+
): HeadingStyleInternal => {
|
|
166
|
+
const fallback = defaultInternal[key];
|
|
167
|
+
return {
|
|
168
|
+
fontSize: style?.fontSize ?? fallback.fontSize,
|
|
169
|
+
fontWeight: style?.fontWeight ?? fallback.fontWeight,
|
|
170
|
+
color: normalizeColor(style?.color) ?? fallback.color,
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
121
174
|
let cachedInput: MarkdownTextInputStyle | undefined;
|
|
122
175
|
let cachedResult: MarkdownTextInputStyleInternal | undefined;
|
|
123
176
|
|
|
@@ -133,10 +186,10 @@ function normalizeInputLinkStyle(
|
|
|
133
186
|
};
|
|
134
187
|
}
|
|
135
188
|
|
|
136
|
-
function
|
|
137
|
-
style:
|
|
138
|
-
fallback:
|
|
139
|
-
):
|
|
189
|
+
function normalizeInlineMathStyle(
|
|
190
|
+
style: InputInlineMathStyle | undefined,
|
|
191
|
+
fallback: InputInlineMathStyleInternal
|
|
192
|
+
): InputInlineMathStyleInternal {
|
|
140
193
|
const color = normalizeColor(style?.color) ?? fallback.color;
|
|
141
194
|
const backgroundColor =
|
|
142
195
|
normalizeColor(style?.backgroundColor) ?? fallback.backgroundColor;
|
|
@@ -159,12 +212,14 @@ function normalizeMathStyle(
|
|
|
159
212
|
};
|
|
160
213
|
}
|
|
161
214
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
215
|
+
// Block math (`markdownStyle.math`). Inherits the chip look from the inline
|
|
216
|
+
// key so a single override styles both, then applies its own block-only fields.
|
|
217
|
+
function normalizeBlockMathStyle(
|
|
218
|
+
style: InputMathStyle | undefined,
|
|
219
|
+
baseInline: InputInlineMathStyleInternal,
|
|
220
|
+
fallback: InputMathStyleInternal
|
|
221
|
+
): InputMathStyleInternal {
|
|
222
|
+
const merged: InputInlineMathStyleInternal = {
|
|
168
223
|
color: baseInline.color,
|
|
169
224
|
fontSize: fallback.fontSize,
|
|
170
225
|
backgroundColor: baseInline.backgroundColor,
|
|
@@ -177,20 +232,28 @@ function normalizeMathBlockStyle(
|
|
|
177
232
|
selectedBorderColor: baseInline.selectedBorderColor,
|
|
178
233
|
fontWeight: baseInline.fontWeight,
|
|
179
234
|
};
|
|
180
|
-
const inheritedInline =
|
|
181
|
-
let
|
|
235
|
+
const inheritedInline = normalizeInlineMathStyle(style, merged);
|
|
236
|
+
let textAlign: 'left' | 'center' | 'right' = fallback.textAlign;
|
|
182
237
|
if (
|
|
183
|
-
style?.
|
|
184
|
-
style?.
|
|
185
|
-
style?.
|
|
238
|
+
style?.textAlign === 'left' ||
|
|
239
|
+
style?.textAlign === 'center' ||
|
|
240
|
+
style?.textAlign === 'right'
|
|
186
241
|
) {
|
|
187
|
-
|
|
242
|
+
textAlign = style.textAlign;
|
|
188
243
|
}
|
|
244
|
+
// `padding` is the renderer-compatible shorthand; the per-axis fields win
|
|
245
|
+
// when both are given. Resolved here so the bridge only ever carries the
|
|
246
|
+
// two axes and no native side has to know about the shorthand.
|
|
247
|
+
const padding = style?.padding;
|
|
189
248
|
return {
|
|
190
249
|
...inheritedInline,
|
|
250
|
+
paddingHorizontal:
|
|
251
|
+
style?.paddingHorizontal ?? padding ?? inheritedInline.paddingHorizontal,
|
|
252
|
+
paddingVertical:
|
|
253
|
+
style?.paddingVertical ?? padding ?? inheritedInline.paddingVertical,
|
|
191
254
|
marginTop: style?.marginTop ?? fallback.marginTop,
|
|
192
255
|
marginBottom: style?.marginBottom ?? fallback.marginBottom,
|
|
193
|
-
|
|
256
|
+
textAlign,
|
|
194
257
|
};
|
|
195
258
|
}
|
|
196
259
|
|
|
@@ -231,14 +294,26 @@ export const normalizeMarkdownTextInputStyle = (
|
|
|
231
294
|
normalizeColor(style.spoiler?.backgroundColor) ??
|
|
232
295
|
defaultInternal.spoiler.backgroundColor,
|
|
233
296
|
},
|
|
234
|
-
|
|
235
|
-
|
|
297
|
+
inlineMath: normalizeInlineMathStyle(
|
|
298
|
+
style.inlineMath,
|
|
299
|
+
defaultInternal.inlineMath
|
|
300
|
+
),
|
|
301
|
+
math: defaultInternal.math,
|
|
302
|
+
h1: normalizeHeadingStyle('h1', style.h1),
|
|
303
|
+
h2: normalizeHeadingStyle('h2', style.h2),
|
|
304
|
+
h3: normalizeHeadingStyle('h3', style.h3),
|
|
305
|
+
h4: normalizeHeadingStyle('h4', style.h4),
|
|
306
|
+
h5: normalizeHeadingStyle('h5', style.h5),
|
|
307
|
+
h6: normalizeHeadingStyle('h6', style.h6),
|
|
308
|
+
list: {
|
|
309
|
+
itemSpacing: style.list?.itemSpacing ?? defaultInternal.list.itemSpacing,
|
|
310
|
+
},
|
|
236
311
|
};
|
|
237
312
|
|
|
238
|
-
result.
|
|
239
|
-
style.
|
|
240
|
-
result.
|
|
241
|
-
defaultInternal.
|
|
313
|
+
result.math = normalizeBlockMathStyle(
|
|
314
|
+
style.math,
|
|
315
|
+
result.inlineMath,
|
|
316
|
+
defaultInternal.math
|
|
242
317
|
);
|
|
243
318
|
|
|
244
319
|
cachedInput = style;
|
package/src/normalizeMenuItem.ts
CHANGED
|
@@ -43,7 +43,7 @@ export const normalizeLegacyBooleanMenuItem = (
|
|
|
43
43
|
if (typeof raw === 'boolean') {
|
|
44
44
|
warnOnce(
|
|
45
45
|
`${parentProp}.${field}`,
|
|
46
|
-
`[react-native-enriched-markdown] ${parentProp}.${field} as a boolean is ` +
|
|
46
|
+
`[react-native-enriched-markdown-scaffold] ${parentProp}.${field} as a boolean is ` +
|
|
47
47
|
`deprecated; use { enabled: ${raw} }. The boolean form will be removed in 0.8.`
|
|
48
48
|
);
|
|
49
49
|
return { enabled: raw, label: defaultLabel };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
type TextAlign = 'auto' | 'left' | 'right' | 'center' | 'justify';
|
|
2
2
|
|
|
3
|
+
type ImageResizeMode = 'contain' | 'cover' | 'stretch' | 'center' | 'none';
|
|
4
|
+
|
|
3
5
|
interface BaseBlockStyle {
|
|
4
6
|
fontSize?: number;
|
|
5
7
|
fontFamily?: string;
|
|
@@ -23,6 +25,8 @@ interface BlockquoteStyle extends BaseBlockStyle {
|
|
|
23
25
|
borderWidth?: number;
|
|
24
26
|
gapWidth?: number;
|
|
25
27
|
backgroundColor?: string;
|
|
28
|
+
borderRadius?: number;
|
|
29
|
+
padding?: number;
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
interface ListStyle extends BaseBlockStyle {
|
|
@@ -37,6 +41,38 @@ interface ListStyle extends BaseBlockStyle {
|
|
|
37
41
|
markerFontWeight?: string;
|
|
38
42
|
gapWidth?: number;
|
|
39
43
|
marginLeft?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Vertical spacing between consecutive list items, including nested ones.
|
|
46
|
+
* Adds no space above the first item or below the last one — the outer
|
|
47
|
+
* edges are still controlled by `marginTop`/`marginBottom`.
|
|
48
|
+
* @default 0
|
|
49
|
+
*/
|
|
50
|
+
itemSpacing?: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Per-token syntax highlight colors for fenced code blocks, keyed on the
|
|
55
|
+
* tree-sitter highlight token types. Any key omitted falls back to the default
|
|
56
|
+
* palette (Operator/Punctuation/Variable/Embedded inherit the code block's
|
|
57
|
+
* base `color`). Colors only take visible effect when the optional syntax
|
|
58
|
+
* highlighting module is compiled in; otherwise code blocks render uncolored.
|
|
59
|
+
*/
|
|
60
|
+
interface CodeBlockSyntaxColors {
|
|
61
|
+
keyword?: string;
|
|
62
|
+
/** Color for operator tokens (e.g. `+`, `=>`). */
|
|
63
|
+
operator?: string;
|
|
64
|
+
punctuation?: string;
|
|
65
|
+
string?: string;
|
|
66
|
+
number?: string;
|
|
67
|
+
constant?: string;
|
|
68
|
+
comment?: string;
|
|
69
|
+
function?: string;
|
|
70
|
+
type?: string;
|
|
71
|
+
variable?: string;
|
|
72
|
+
property?: string;
|
|
73
|
+
tag?: string;
|
|
74
|
+
attribute?: string;
|
|
75
|
+
embedded?: string;
|
|
40
76
|
}
|
|
41
77
|
|
|
42
78
|
interface CodeBlockStyle extends BaseBlockStyle {
|
|
@@ -45,6 +81,7 @@ interface CodeBlockStyle extends BaseBlockStyle {
|
|
|
45
81
|
borderRadius?: number;
|
|
46
82
|
borderWidth?: number;
|
|
47
83
|
padding?: number;
|
|
84
|
+
syntaxColors?: CodeBlockSyntaxColors;
|
|
48
85
|
}
|
|
49
86
|
|
|
50
87
|
export interface LinkStyle {
|
|
@@ -108,6 +145,26 @@ interface CodeStyle {
|
|
|
108
145
|
|
|
109
146
|
interface ImageStyle {
|
|
110
147
|
height?: number;
|
|
148
|
+
/**
|
|
149
|
+
* Maximum height the image is fitted into, preserving aspect ratio. When set,
|
|
150
|
+
* this replaces `height` as the primary sizing knob. Ignored when `aspectRatio`
|
|
151
|
+
* is set. Sizing precedence: `aspectRatio` > `maxHeight` > `height`.
|
|
152
|
+
*/
|
|
153
|
+
maxHeight?: number;
|
|
154
|
+
/**
|
|
155
|
+
* Width / height ratio (e.g. `16 / 9`). The image fills the available width and
|
|
156
|
+
* its height is derived from this ratio, ignoring `height`/`maxHeight`.
|
|
157
|
+
* Sizing precedence: `aspectRatio` > `maxHeight` > `height`.
|
|
158
|
+
*/
|
|
159
|
+
aspectRatio?: number;
|
|
160
|
+
/**
|
|
161
|
+
* How the image fills its box, analogous to React Native `resizeMode` / CSS
|
|
162
|
+
* `object-fit`. Applies whenever set explicitly, including with a fixed
|
|
163
|
+
* `height` box. When omitted, block images keep the legacy fill-width
|
|
164
|
+
* behavior, unless `maxHeight` or `aspectRatio` is set — then it defaults
|
|
165
|
+
* to `'cover'`.
|
|
166
|
+
*/
|
|
167
|
+
resizeMode?: ImageResizeMode;
|
|
111
168
|
borderRadius?: number;
|
|
112
169
|
marginTop?: number;
|
|
113
170
|
marginBottom?: number;
|
|
@@ -135,6 +192,16 @@ interface TableStyle extends BaseBlockStyle {
|
|
|
135
192
|
borderRadius?: number;
|
|
136
193
|
cellPaddingHorizontal?: number;
|
|
137
194
|
cellPaddingVertical?: number;
|
|
195
|
+
horizontalOverflow?: number;
|
|
196
|
+
/**
|
|
197
|
+
* Horizontal alignment of the whole table within the container. Only applies
|
|
198
|
+
* when the table is narrower than the container; tables that overflow and
|
|
199
|
+
* scroll always start at the table's beginning. When unset, tables keep the
|
|
200
|
+
* legacy start-aligned placement. On web, setting any value (including
|
|
201
|
+
* 'left') also makes the table shrink to fit its content instead of filling
|
|
202
|
+
* the container width.
|
|
203
|
+
*/
|
|
204
|
+
align?: 'left' | 'center' | 'right';
|
|
138
205
|
}
|
|
139
206
|
|
|
140
207
|
interface TaskListStyle {
|
|
@@ -355,4 +422,11 @@ export interface Md4cFlags {
|
|
|
355
422
|
* @default false
|
|
356
423
|
*/
|
|
357
424
|
highlight?: boolean;
|
|
425
|
+
/**
|
|
426
|
+
* Treat soft breaks (single newlines) as hard breaks (visible line breaks).
|
|
427
|
+
* When enabled, a single newline in the source renders as a line break
|
|
428
|
+
* instead of being collapsed to a space (CommonMark default).
|
|
429
|
+
* @default false
|
|
430
|
+
*/
|
|
431
|
+
hardSoftBreaks?: boolean;
|
|
358
432
|
}
|
|
@@ -6,6 +6,19 @@ export type BlockTextAlign = 'auto' | 'left' | 'right' | 'center' | 'justify';
|
|
|
6
6
|
// Mirrors the public fontStyle values; empty string means "inherit / no override".
|
|
7
7
|
export type EmphasisFontStyle = 'normal' | 'italic' | 'oblique' | '';
|
|
8
8
|
|
|
9
|
+
// empty string means "no table alignment set" (legacy start-aligned placement).
|
|
10
|
+
export type TableAlign = 'left' | 'center' | 'right' | '';
|
|
11
|
+
|
|
12
|
+
// empty string means "legacy sizing" (fill width, no resize-mode handling).
|
|
13
|
+
// resolves to 'cover' when maxHeight/aspectRatio is present.
|
|
14
|
+
export type ImageResizeMode =
|
|
15
|
+
| 'contain'
|
|
16
|
+
| 'cover'
|
|
17
|
+
| 'stretch'
|
|
18
|
+
| 'center'
|
|
19
|
+
| 'none'
|
|
20
|
+
| '';
|
|
21
|
+
|
|
9
22
|
interface BaseBlockStyleInternal {
|
|
10
23
|
fontSize: number;
|
|
11
24
|
fontFamily: string;
|
|
@@ -29,6 +42,8 @@ interface BlockquoteStyleInternal extends BaseBlockStyleInternal {
|
|
|
29
42
|
borderWidth: number;
|
|
30
43
|
gapWidth: number;
|
|
31
44
|
backgroundColor: string;
|
|
45
|
+
borderRadius: number;
|
|
46
|
+
padding: number;
|
|
32
47
|
}
|
|
33
48
|
|
|
34
49
|
interface ListStyleInternal extends BaseBlockStyleInternal {
|
|
@@ -39,6 +54,24 @@ interface ListStyleInternal extends BaseBlockStyleInternal {
|
|
|
39
54
|
markerFontWeight: string;
|
|
40
55
|
gapWidth: number;
|
|
41
56
|
marginLeft: number;
|
|
57
|
+
itemSpacing: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface CodeBlockSyntaxColorsInternal {
|
|
61
|
+
keyword: string;
|
|
62
|
+
operatorColor: string;
|
|
63
|
+
punctuation: string;
|
|
64
|
+
string: string;
|
|
65
|
+
number: string;
|
|
66
|
+
constant: string;
|
|
67
|
+
comment: string;
|
|
68
|
+
function: string;
|
|
69
|
+
type: string;
|
|
70
|
+
variable: string;
|
|
71
|
+
property: string;
|
|
72
|
+
tag: string;
|
|
73
|
+
attribute: string;
|
|
74
|
+
embedded: string;
|
|
42
75
|
}
|
|
43
76
|
|
|
44
77
|
interface CodeBlockStyleInternal extends BaseBlockStyleInternal {
|
|
@@ -47,6 +80,7 @@ interface CodeBlockStyleInternal extends BaseBlockStyleInternal {
|
|
|
47
80
|
borderRadius: number;
|
|
48
81
|
borderWidth: number;
|
|
49
82
|
padding: number;
|
|
83
|
+
syntaxColors: CodeBlockSyntaxColorsInternal;
|
|
50
84
|
}
|
|
51
85
|
|
|
52
86
|
interface LinkStyleInternal {
|
|
@@ -93,6 +127,9 @@ interface CodeStyleInternal {
|
|
|
93
127
|
|
|
94
128
|
interface ImageStyleInternal {
|
|
95
129
|
height: number;
|
|
130
|
+
maxHeight: number;
|
|
131
|
+
aspectRatio: number;
|
|
132
|
+
resizeMode: ImageResizeMode;
|
|
96
133
|
borderRadius: number;
|
|
97
134
|
marginTop: number;
|
|
98
135
|
marginBottom: number;
|
|
@@ -120,6 +157,8 @@ interface TableStyleInternal extends BaseBlockStyleInternal {
|
|
|
120
157
|
borderRadius: number;
|
|
121
158
|
cellPaddingHorizontal: number;
|
|
122
159
|
cellPaddingVertical: number;
|
|
160
|
+
horizontalOverflow: number;
|
|
161
|
+
align: TableAlign;
|
|
123
162
|
}
|
|
124
163
|
|
|
125
164
|
interface TaskListStyleInternal {
|