react-native-enriched-markdown-scaffold 0.7.4-scaffold.9 → 1.0.2-scaffold.10
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 +188 -1
- package/android/consumer-rules.pro +1 -1
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +27 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +7 -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 +27 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +7 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +223 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +183 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +65 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +1086 -61
- 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 +351 -13
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +62 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +85 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +160 -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 +76 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +126 -10
- package/android/src/main/java/com/swmansion/enriched/markdown/events/CopyPressEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/CopyRequestEvent.kt +28 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/LinkLayoutEvent.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/SelectionChangeEvent.kt +43 -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 +923 -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 +108 -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/LinkRenderer.kt +37 -7
- 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 +35 -28
- 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 +20 -82
- 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/InlineChipPainter.kt +140 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkChipSpans.kt +177 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt +1 -6
- 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/InlineMathStyle.kt +16 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkStyle.kt +36 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkVariantEntry.kt +7 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ListStyle.kt +4 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathStyle.kt +3 -0
- 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 +84 -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 +52 -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/conversion/HTMLGenerator.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/MarkdownExtractor.kt +6 -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/HeadlessActionMode.kt +88 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLayoutCollector.kt +100 -0
- 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 +72 -16
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionChangeReporter.kt +232 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/BlockMenuOptions.kt +64 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/CodeBlockContainerView.kt +414 -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 +61 -11
- 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 +8 -2
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathChipSpan.kt +1 -1
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +13 -6
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathMeasureHelper.kt +2 -1
- package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +26 -8
- 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 +405 -12
- package/docs/BREAKING_CHANGES.md +129 -0
- package/docs/CODE_HIGHLIGHT.md +133 -0
- package/docs/COPY_OPTIONS.md +61 -3
- package/docs/ELEMENTS_STRUCTURE.md +52 -4
- package/docs/IMAGE_CACHING.md +30 -0
- package/docs/INPUT.md +110 -11
- package/docs/LATEX_MATH.md +87 -45
- package/docs/MACOS.md +1 -1
- package/docs/MARKDOWN_STREAMING.md +27 -1
- package/docs/MENTIONS.md +8 -1
- package/docs/NATIVE_ASSETS.md +127 -0
- package/docs/RTL.md +1 -1
- package/docs/STYLES.md +73 -6
- package/docs/TESTING.md +112 -0
- package/docs/TEXT.md +18 -6
- package/docs/WEB.md +4 -1
- package/ios/EnrichedMarkdown.h +7 -0
- package/ios/EnrichedMarkdown.mm +583 -76
- package/ios/EnrichedMarkdownText.h +7 -0
- package/ios/EnrichedMarkdownText.mm +299 -73
- package/ios/attachments/ENRMImageAttachment.h +9 -0
- package/ios/attachments/ENRMImageAttachment.m +143 -40
- package/ios/attachments/ENRMMathInlineAttachment+macOS.m +2 -1
- package/ios/attachments/ENRMMathInlineAttachment.h +5 -0
- package/ios/attachments/ENRMMathInlineAttachment.m +50 -82
- package/ios/attachments/ENRMMathInlineAttachmentShared.h +2 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +223 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +183 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +65 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +1086 -61
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/RCTComponentViewHelpers.h +181 -2
- 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 +41 -9
- 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 +27 -6
- 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 +6 -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 +50 -16
- 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 +42 -0
- package/ios/styles/StyleConfig.mm +216 -0
- package/ios/utils/BlockquoteBorder.h +6 -0
- package/ios/utils/BlockquoteBorder.m +249 -52
- package/ios/utils/CodeBackground.m +3 -65
- package/ios/utils/CodeBlockBackground.m +16 -2
- package/ios/utils/ENRMAtomicSize.h +65 -0
- package/ios/utils/ENRMBlockMenu.h +66 -0
- package/ios/utils/ENRMChipDrawing.h +24 -0
- package/ios/utils/ENRMChipDrawing.m +83 -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/ENRMLinkChip.h +70 -0
- package/ios/utils/ENRMLinkChip.m +213 -0
- package/ios/utils/ENRMLinkLayout.h +50 -0
- package/ios/utils/ENRMLinkLayout.m +45 -0
- 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/ENRMSelectionChange.h +120 -0
- package/ios/utils/ENRMSelectionChange.m +282 -0
- package/ios/utils/ENRMTextViewSetup.h +35 -17
- package/ios/utils/EditMenuUtils+macOS.m +4 -1
- package/ios/utils/EditMenuUtils.h +35 -6
- package/ios/utils/EditMenuUtils.m +188 -11
- package/ios/utils/HTMLGenerator.m +2 -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/MarkdownAccessibilityElementBuilder.m +3 -1
- package/ios/utils/MarkdownExtractor.m +2 -1
- package/ios/utils/ParagraphStyleUtils.h +5 -0
- package/ios/utils/ParagraphStyleUtils.m +77 -17
- package/ios/utils/RTFExportUtils.m +2 -0
- 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 +110 -1
- package/ios/utils/TaskListTapUtils.m +24 -0
- package/ios/utils/TextViewLayoutManager.mm +3 -0
- package/ios/views/ENRMCodeBlockContainerView.h +60 -0
- package/ios/views/ENRMCodeBlockContainerView.m +569 -0
- package/ios/views/ENRMMathContainerView.h +23 -0
- package/ios/views/ENRMMathContainerView.m +87 -20
- package/ios/views/TableContainerView.h +32 -0
- package/ios/views/TableContainerView.m +291 -175
- package/jest.d.ts +1 -0
- package/jest.js +5 -0
- package/lib/module/EnrichedMarkdownNativeComponent.ts +203 -1
- 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 +204 -1
- 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 +205 -0
- package/lib/module/jest/index.js.map +1 -0
- package/lib/module/native/EnrichedMarkdownText.js +199 -15
- package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.js +98 -23
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.web.js +73 -22
- 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 +15 -8
- 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 +102 -3
- 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 +101 -6
- package/lib/module/web/styles.js.map +1 -1
- package/lib/module/web/utils.js +14 -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 +185 -2
- 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 +185 -2
- 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 +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +2 -2
- 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 +5 -5
- 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 +122 -5
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +39 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.d.ts +207 -10
- package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +60 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -1
- package/lib/typescript/src/types/events.d.ts +85 -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 +10 -2
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/lib/typescript/src/web/utils.d.ts +4 -0
- 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 +203 -1
- package/src/EnrichedMarkdownTextInput.tsx +159 -8
- package/src/EnrichedMarkdownTextInputNativeComponent.ts +78 -5
- package/src/EnrichedMarkdownTextNativeComponent.ts +204 -1
- package/src/headingDefaults.ts +21 -0
- package/src/index.tsx +15 -0
- package/src/index.web.tsx +6 -1
- package/src/jest/index.tsx +236 -0
- package/src/native/EnrichedMarkdownText.tsx +260 -11
- package/src/normalizeMarkdownStyle.ts +117 -16
- package/src/normalizeMarkdownStyle.web.ts +76 -15
- package/src/normalizeMarkdownTextInputStyle.ts +110 -35
- package/src/normalizeMenuItem.ts +1 -1
- package/src/types/MarkdownStyle.ts +125 -5
- package/src/types/MarkdownStyleInternal.ts +51 -0
- package/src/types/MarkdownTextProps.ts +215 -10
- package/src/types/MarkdownTextProps.web.ts +62 -1
- package/src/types/events.ts +90 -0
- package/src/utils/textInputState.ts +35 -0
- package/src/web/EnrichedMarkdownText.tsx +26 -5
- package/src/web/parseMarkdown.ts +6 -2
- package/src/web/renderers/InlineRenderers.tsx +116 -3
- package/src/web/renderers/ListRenderers.tsx +14 -2
- package/src/web/renderers/index.tsx +6 -2
- package/src/web/styles.ts +114 -5
- package/src/web/types.ts +10 -1
- package/src/web/utils.ts +9 -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
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
codegenNativeComponent,
|
|
3
|
+
codegenNativeCommands,
|
|
3
4
|
type ViewProps,
|
|
4
5
|
type CodegenTypes,
|
|
5
6
|
type ColorValue,
|
|
7
|
+
type HostComponent,
|
|
6
8
|
} from 'react-native';
|
|
9
|
+
import type React from 'react';
|
|
7
10
|
|
|
8
11
|
// All block styles extend this interface
|
|
9
12
|
interface BaseBlockStyleInternal {
|
|
@@ -29,6 +32,8 @@ interface BlockquoteStyleInternal extends BaseBlockStyleInternal {
|
|
|
29
32
|
borderWidth: CodegenTypes.Float;
|
|
30
33
|
gapWidth: CodegenTypes.Float;
|
|
31
34
|
backgroundColor: ColorValue;
|
|
35
|
+
borderRadius: CodegenTypes.Float;
|
|
36
|
+
padding: CodegenTypes.Float;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
interface ListStyleInternal extends BaseBlockStyleInternal {
|
|
@@ -39,6 +44,24 @@ interface ListStyleInternal extends BaseBlockStyleInternal {
|
|
|
39
44
|
markerFontWeight: string;
|
|
40
45
|
gapWidth: CodegenTypes.Float;
|
|
41
46
|
marginLeft: CodegenTypes.Float;
|
|
47
|
+
itemSpacing: CodegenTypes.Float;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface CodeBlockSyntaxColorsInternal {
|
|
51
|
+
keyword: ColorValue;
|
|
52
|
+
operatorColor: ColorValue;
|
|
53
|
+
punctuation: ColorValue;
|
|
54
|
+
string: ColorValue;
|
|
55
|
+
number: ColorValue;
|
|
56
|
+
constant: ColorValue;
|
|
57
|
+
comment: ColorValue;
|
|
58
|
+
function: ColorValue;
|
|
59
|
+
type: ColorValue;
|
|
60
|
+
variable: ColorValue;
|
|
61
|
+
property: ColorValue;
|
|
62
|
+
tag: ColorValue;
|
|
63
|
+
attribute: ColorValue;
|
|
64
|
+
embedded: ColorValue;
|
|
42
65
|
}
|
|
43
66
|
|
|
44
67
|
interface CodeBlockStyleInternal extends BaseBlockStyleInternal {
|
|
@@ -47,6 +70,7 @@ interface CodeBlockStyleInternal extends BaseBlockStyleInternal {
|
|
|
47
70
|
borderRadius: CodegenTypes.Float;
|
|
48
71
|
borderWidth: CodegenTypes.Float;
|
|
49
72
|
padding: CodegenTypes.Float;
|
|
73
|
+
syntaxColors: CodeBlockSyntaxColorsInternal;
|
|
50
74
|
}
|
|
51
75
|
|
|
52
76
|
interface LinkStyleInternal {
|
|
@@ -54,6 +78,11 @@ interface LinkStyleInternal {
|
|
|
54
78
|
color: ColorValue;
|
|
55
79
|
underline: boolean;
|
|
56
80
|
backgroundColor: ColorValue;
|
|
81
|
+
borderRadius: CodegenTypes.Float;
|
|
82
|
+
paddingHorizontal: CodegenTypes.Float;
|
|
83
|
+
paddingVertical: CodegenTypes.Float;
|
|
84
|
+
borderColor: ColorValue;
|
|
85
|
+
borderWidth: CodegenTypes.Float;
|
|
57
86
|
}
|
|
58
87
|
|
|
59
88
|
// Mirrors EnrichedMarkdownNativeComponent.ts — kept in sync manually (codegen spec files must be self-contained).
|
|
@@ -62,6 +91,11 @@ interface LinkVariantEntryInternal {
|
|
|
62
91
|
color: ColorValue;
|
|
63
92
|
underline: boolean;
|
|
64
93
|
backgroundColor: ColorValue;
|
|
94
|
+
borderRadius: CodegenTypes.Float;
|
|
95
|
+
paddingHorizontal: CodegenTypes.Float;
|
|
96
|
+
paddingVertical: CodegenTypes.Float;
|
|
97
|
+
borderColor: ColorValue;
|
|
98
|
+
borderWidth: CodegenTypes.Float;
|
|
65
99
|
}
|
|
66
100
|
|
|
67
101
|
interface StrongStyleInternal {
|
|
@@ -94,6 +128,10 @@ interface CodeStyleInternal {
|
|
|
94
128
|
|
|
95
129
|
interface ImageStyleInternal {
|
|
96
130
|
height: CodegenTypes.Float;
|
|
131
|
+
maxHeight: CodegenTypes.Float;
|
|
132
|
+
aspectRatio: CodegenTypes.Float;
|
|
133
|
+
// Nested struct fields cannot use WithDefault; default is applied in JS normalization.
|
|
134
|
+
resizeMode: string;
|
|
97
135
|
borderRadius: CodegenTypes.Float;
|
|
98
136
|
marginTop: CodegenTypes.Float;
|
|
99
137
|
marginBottom: CodegenTypes.Float;
|
|
@@ -121,6 +159,8 @@ interface TableStyleInternal extends BaseBlockStyleInternal {
|
|
|
121
159
|
borderRadius: CodegenTypes.Float;
|
|
122
160
|
cellPaddingHorizontal: CodegenTypes.Float;
|
|
123
161
|
cellPaddingVertical: CodegenTypes.Float;
|
|
162
|
+
horizontalOverflow: CodegenTypes.Float;
|
|
163
|
+
align: string;
|
|
124
164
|
}
|
|
125
165
|
|
|
126
166
|
interface TaskListStyleInternal {
|
|
@@ -142,12 +182,14 @@ interface MathStyleInternal {
|
|
|
142
182
|
marginBottom: CodegenTypes.Float;
|
|
143
183
|
textAlign: string;
|
|
144
184
|
fontWeight: string;
|
|
185
|
+
glyphOverflow: CodegenTypes.Float;
|
|
145
186
|
}
|
|
146
187
|
|
|
147
188
|
interface InlineMathStyleInternal {
|
|
148
189
|
color: ColorValue;
|
|
149
190
|
paddingVertical: CodegenTypes.Float;
|
|
150
191
|
fontWeight: string;
|
|
192
|
+
glyphOverflow: CodegenTypes.Float;
|
|
151
193
|
}
|
|
152
194
|
|
|
153
195
|
interface SpoilerParticlesStyleInternal {
|
|
@@ -219,17 +261,88 @@ export interface LinkLongPressEvent {
|
|
|
219
261
|
url: string;
|
|
220
262
|
}
|
|
221
263
|
|
|
264
|
+
/**
|
|
265
|
+
* `fragments` holds one entry per laid-out line of a link (a wrapping link
|
|
266
|
+
* yields several). Rects are in dp, relative to the native view's origin, and
|
|
267
|
+
* cover the drawn chip (glyphs + padding). Flattened rather than nested per
|
|
268
|
+
* link, and written inline, because codegen only accepts inline object
|
|
269
|
+
* literals as event array elements.
|
|
270
|
+
*/
|
|
271
|
+
export interface LinkLayoutEvent {
|
|
272
|
+
fragments: {
|
|
273
|
+
linkIndex: CodegenTypes.Int32;
|
|
274
|
+
url: string;
|
|
275
|
+
text: string;
|
|
276
|
+
x: CodegenTypes.Double;
|
|
277
|
+
y: CodegenTypes.Double;
|
|
278
|
+
width: CodegenTypes.Double;
|
|
279
|
+
height: CodegenTypes.Double;
|
|
280
|
+
}[];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Current text selection, or a long-pressed table / math / code block while
|
|
285
|
+
* `contextMenuHidden` is on. `active: false` means the selection was cleared
|
|
286
|
+
* (every other field is then empty / zero). Rects are in dp / pt, relative to
|
|
287
|
+
* the native view's origin; rect objects are written inline because codegen
|
|
288
|
+
* only accepts inline object literals in event payloads.
|
|
289
|
+
*/
|
|
290
|
+
export interface SelectionChangeEvent {
|
|
291
|
+
active: boolean;
|
|
292
|
+
source: string;
|
|
293
|
+
text: string;
|
|
294
|
+
markdown: string;
|
|
295
|
+
whole: boolean;
|
|
296
|
+
rect: {
|
|
297
|
+
x: CodegenTypes.Double;
|
|
298
|
+
y: CodegenTypes.Double;
|
|
299
|
+
width: CodegenTypes.Double;
|
|
300
|
+
height: CodegenTypes.Double;
|
|
301
|
+
};
|
|
302
|
+
startRect: {
|
|
303
|
+
x: CodegenTypes.Double;
|
|
304
|
+
y: CodegenTypes.Double;
|
|
305
|
+
width: CodegenTypes.Double;
|
|
306
|
+
height: CodegenTypes.Double;
|
|
307
|
+
};
|
|
308
|
+
endRect: {
|
|
309
|
+
x: CodegenTypes.Double;
|
|
310
|
+
y: CodegenTypes.Double;
|
|
311
|
+
width: CodegenTypes.Double;
|
|
312
|
+
height: CodegenTypes.Double;
|
|
313
|
+
};
|
|
314
|
+
adjusting: boolean;
|
|
315
|
+
}
|
|
316
|
+
|
|
222
317
|
export interface TaskListItemPressEvent {
|
|
223
318
|
index: CodegenTypes.Int32;
|
|
224
319
|
checked: boolean;
|
|
225
320
|
text: string;
|
|
226
321
|
}
|
|
227
322
|
|
|
323
|
+
export interface CopyPressEvent {
|
|
324
|
+
code: string;
|
|
325
|
+
language: string;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export interface CopyRequestEvent {
|
|
329
|
+
// 'selection' | 'math' | 'table' | 'code'
|
|
330
|
+
source: string;
|
|
331
|
+
markdown: string;
|
|
332
|
+
text: string;
|
|
333
|
+
whole: boolean;
|
|
334
|
+
}
|
|
335
|
+
|
|
228
336
|
export interface ContextMenuItemConfig {
|
|
229
337
|
text: string;
|
|
230
338
|
icon?: string;
|
|
231
339
|
}
|
|
232
340
|
|
|
341
|
+
export interface ImageRequestHeaderInternal {
|
|
342
|
+
name: string;
|
|
343
|
+
value: string;
|
|
344
|
+
}
|
|
345
|
+
|
|
233
346
|
export interface SelectionMenuConfig {
|
|
234
347
|
copyAsMarkdown: boolean;
|
|
235
348
|
copyImageUrl: boolean;
|
|
@@ -240,6 +353,16 @@ export interface SelectionMenuConfig {
|
|
|
240
353
|
// Precomputed plural templates indexed by image count (0..100). Empty when no
|
|
241
354
|
// pluralLabels are set; native then uses copyImageUrlLabel/copyImageUrlsLabel.
|
|
242
355
|
copyImageUrlPluralTemplates: ReadonlyArray<string>;
|
|
356
|
+
// false removes the Copy item from the text and block menus.
|
|
357
|
+
copyEnabled: boolean;
|
|
358
|
+
// true: Copy writes Markdown (plain text) instead of rich text / raw block content.
|
|
359
|
+
copyFormatMarkdown: boolean;
|
|
360
|
+
// true: the text selection menu drops every system-provided item.
|
|
361
|
+
systemItemsNone: boolean;
|
|
362
|
+
// false hides the copy button in the code block header.
|
|
363
|
+
codeBlockCopyButton: boolean;
|
|
364
|
+
// true: the Copy item emits onCopyRequest instead of writing the clipboard.
|
|
365
|
+
interceptCopy: boolean;
|
|
243
366
|
}
|
|
244
367
|
|
|
245
368
|
export interface OnContextMenuItemPressEvent {
|
|
@@ -311,10 +434,16 @@ export interface Md4cFlagsInternal {
|
|
|
311
434
|
* @default false
|
|
312
435
|
*/
|
|
313
436
|
highlight: boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Treat soft breaks (single newlines) as hard breaks (visible line breaks).
|
|
439
|
+
* @default false
|
|
440
|
+
*/
|
|
441
|
+
hardSoftBreaks: boolean;
|
|
314
442
|
}
|
|
315
443
|
|
|
316
444
|
interface StreamingConfigInternal {
|
|
317
445
|
tableMode: string;
|
|
446
|
+
codeBlockMode: string;
|
|
318
447
|
}
|
|
319
448
|
|
|
320
449
|
export interface NativeProps extends ViewProps {
|
|
@@ -340,11 +469,56 @@ export interface NativeProps extends ViewProps {
|
|
|
340
469
|
* - Android: Handles long press gestures on links.
|
|
341
470
|
*/
|
|
342
471
|
onLinkLongPress?: CodegenTypes.BubblingEventHandler<LinkLongPressEvent>;
|
|
472
|
+
/**
|
|
473
|
+
* When true, the view reports the laid-out rects of every link through
|
|
474
|
+
* `onLinkLayout` (after each render and whenever its size changes).
|
|
475
|
+
* Set by the JS wrapper only when `renderLinkDecoration` is provided.
|
|
476
|
+
* @default false
|
|
477
|
+
*/
|
|
478
|
+
emitLinkLayout?: CodegenTypes.WithDefault<boolean, false>;
|
|
479
|
+
/**
|
|
480
|
+
* Fired with the rects of every link fragment while `emitLinkLayout` is on.
|
|
481
|
+
* Deduplicated: not re-fired when the payload is unchanged.
|
|
482
|
+
*/
|
|
483
|
+
onLinkLayout?: CodegenTypes.DirectEventHandler<LinkLayoutEvent>;
|
|
484
|
+
/**
|
|
485
|
+
* When true, the view reports selection changes (and, with
|
|
486
|
+
* `contextMenuHidden`, block long-presses) through `onSelectionChange`.
|
|
487
|
+
* Set by the JS wrapper only when `onSelectionChange` is provided.
|
|
488
|
+
* @default false
|
|
489
|
+
*/
|
|
490
|
+
emitSelectionChange?: CodegenTypes.WithDefault<boolean, false>;
|
|
491
|
+
/**
|
|
492
|
+
* Fired while `emitSelectionChange` is on: coalesced to one event per frame,
|
|
493
|
+
* deduplicated, and `active: false` once the selection is gone.
|
|
494
|
+
*/
|
|
495
|
+
onSelectionChange?: CodegenTypes.DirectEventHandler<SelectionChangeEvent>;
|
|
343
496
|
/**
|
|
344
497
|
* Callback fired when a task list checkbox is tapped.
|
|
345
498
|
* Receives the 0-based task index, current checked state, and the item's plain text.
|
|
346
499
|
*/
|
|
347
500
|
onTaskListItemPress?: CodegenTypes.BubblingEventHandler<TaskListItemPressEvent>;
|
|
501
|
+
/**
|
|
502
|
+
* Controls whether tapping a task list checkbox toggles its checked state.
|
|
503
|
+
*
|
|
504
|
+
* When `false`, the tap is fully inert: no visual toggle and no
|
|
505
|
+
* `onTaskListItemPress` emission. Text selection and links are unaffected.
|
|
506
|
+
*
|
|
507
|
+
* @default true
|
|
508
|
+
*/
|
|
509
|
+
enableTaskListItemToggle?: CodegenTypes.WithDefault<boolean, true>;
|
|
510
|
+
/**
|
|
511
|
+
* Callback fired when code is copied from a fenced code block's header copy
|
|
512
|
+
* button, its long-press context-menu "Copy" action, or the VoiceOver copy
|
|
513
|
+
* action. Receives the copied code and its language.
|
|
514
|
+
*/
|
|
515
|
+
onCopyPress?: CodegenTypes.BubblingEventHandler<CopyPressEvent>;
|
|
516
|
+
/**
|
|
517
|
+
* Fired instead of writing the clipboard when the Copy item of the text
|
|
518
|
+
* selection menu or a table / math / code block menu is pressed while
|
|
519
|
+
* `selectionMenuConfig.interceptCopy` is set.
|
|
520
|
+
*/
|
|
521
|
+
onCopyRequest?: CodegenTypes.BubblingEventHandler<CopyRequestEvent>;
|
|
348
522
|
/**
|
|
349
523
|
* Controls whether the system link preview is shown on long press (iOS only).
|
|
350
524
|
*
|
|
@@ -358,6 +532,16 @@ export interface NativeProps extends ViewProps {
|
|
|
358
532
|
* @default true
|
|
359
533
|
*/
|
|
360
534
|
enableLinkPreview?: CodegenTypes.WithDefault<boolean, true>;
|
|
535
|
+
/**
|
|
536
|
+
* When `true`, long-pressing a link selects its label and shows the
|
|
537
|
+
* selection edit menu instead of the system link preview (iOS only).
|
|
538
|
+
* Takes precedence over `enableLinkPreview` and `onLinkLongPress`.
|
|
539
|
+
*
|
|
540
|
+
* Android: No-op.
|
|
541
|
+
*
|
|
542
|
+
* @default false
|
|
543
|
+
*/
|
|
544
|
+
linkLongPressSelects?: CodegenTypes.WithDefault<boolean, false>;
|
|
361
545
|
/**
|
|
362
546
|
* - iOS: Controls text selection and link previews on long press.
|
|
363
547
|
* - Android: Controls text selection.
|
|
@@ -424,10 +608,18 @@ export interface NativeProps extends ViewProps {
|
|
|
424
608
|
* @default 'particles'
|
|
425
609
|
*/
|
|
426
610
|
spoilerOverlay?: CodegenTypes.WithDefault<string, 'particles'>;
|
|
611
|
+
/**
|
|
612
|
+
* Hides the text selection context menu while keeping text selectable.
|
|
613
|
+
*/
|
|
614
|
+
contextMenuHidden?: CodegenTypes.WithDefault<boolean, false>;
|
|
427
615
|
/**
|
|
428
616
|
* Custom items to show in the text selection context menu.
|
|
429
617
|
*/
|
|
430
618
|
contextMenuItems?: ReadonlyArray<Readonly<ContextMenuItemConfig>>;
|
|
619
|
+
/**
|
|
620
|
+
* HTTP headers attached to remote image requests, as name/value pairs.
|
|
621
|
+
*/
|
|
622
|
+
imageRequestHeaders?: ReadonlyArray<Readonly<ImageRequestHeaderInternal>>;
|
|
431
623
|
/**
|
|
432
624
|
* Built-in items to show in the text selection context menu.
|
|
433
625
|
*/
|
|
@@ -463,6 +655,17 @@ export interface NativeProps extends ViewProps {
|
|
|
463
655
|
writingDirection?: CodegenTypes.WithDefault<string, 'first-strong'>;
|
|
464
656
|
}
|
|
465
657
|
|
|
658
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
659
|
+
|
|
660
|
+
interface NativeCommands {
|
|
661
|
+
/** Clears the text selection (and any active block) and fires `onSelectionChange` with `active: false`. */
|
|
662
|
+
clearSelection: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
666
|
+
supportedCommands: ['clearSelection'],
|
|
667
|
+
});
|
|
668
|
+
|
|
466
669
|
export default codegenNativeComponent<NativeProps>('EnrichedMarkdownText', {
|
|
467
670
|
interfaceOnly: true,
|
|
468
|
-
})
|
|
671
|
+
}) as HostComponent<NativeProps>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Single source of truth for default heading appearance, shared by the
|
|
2
|
+
// read-only renderer and the editable input so headings match across views.
|
|
3
|
+
|
|
4
|
+
export type HeadingLevelKey = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
5
|
+
|
|
6
|
+
export interface HeadingDefault {
|
|
7
|
+
fontSize: number;
|
|
8
|
+
color: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Default font weight applied to every heading level. */
|
|
12
|
+
export const DEFAULT_HEADING_FONT_WEIGHT = 'bold';
|
|
13
|
+
|
|
14
|
+
export const HEADING_DEFAULTS: Record<HeadingLevelKey, HeadingDefault> = {
|
|
15
|
+
h1: { fontSize: 30, color: '#111827' },
|
|
16
|
+
h2: { fontSize: 24, color: '#111827' },
|
|
17
|
+
h3: { fontSize: 20, color: '#111827' },
|
|
18
|
+
h4: { fontSize: 18, color: '#111827' },
|
|
19
|
+
h5: { fontSize: 16, color: '#374151' },
|
|
20
|
+
h6: { fontSize: 14, color: '#4B5563' },
|
|
21
|
+
};
|
package/src/index.tsx
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
export { default as EnrichedMarkdownText } from './native/EnrichedMarkdownText';
|
|
2
2
|
export type {
|
|
3
3
|
EnrichedMarkdownTextProps,
|
|
4
|
+
EnrichedMarkdownTextInstance,
|
|
4
5
|
StreamingConfig,
|
|
5
6
|
MarkdownStyle,
|
|
6
7
|
Md4cFlags,
|
|
7
8
|
ContextMenuItem as TextContextMenuItem,
|
|
8
9
|
SelectionMenuConfig as TextSelectionMenuConfig,
|
|
9
10
|
SelectionMenuPluralLabels as TextSelectionMenuPluralLabels,
|
|
11
|
+
LinkDecorationInfo,
|
|
12
|
+
LinkRect,
|
|
10
13
|
} from './native/EnrichedMarkdownText';
|
|
11
14
|
export type {
|
|
12
15
|
LinkPressEvent,
|
|
13
16
|
LinkLongPressEvent,
|
|
14
17
|
TaskListItemPressEvent,
|
|
18
|
+
CopyPressEvent,
|
|
19
|
+
CopyEvent,
|
|
20
|
+
OnPasteEvent,
|
|
21
|
+
SelectionChangeEvent,
|
|
22
|
+
SelectionRect,
|
|
15
23
|
} from './types/events';
|
|
16
24
|
export type {
|
|
17
25
|
AccessibilityLabels,
|
|
@@ -31,9 +39,16 @@ export type {
|
|
|
31
39
|
ContextMenuItem,
|
|
32
40
|
InputSelectionMenuConfig,
|
|
33
41
|
FormatMenuConfig,
|
|
42
|
+
OnKeyPressEvent,
|
|
34
43
|
OnLinkDetected,
|
|
35
44
|
OnStartMentionEvent,
|
|
36
45
|
OnChangeMentionEvent,
|
|
37
46
|
OnEndMentionEvent,
|
|
38
47
|
CaretRect,
|
|
48
|
+
HeadingLevel,
|
|
49
|
+
HeadingStyle,
|
|
50
|
+
InputInlineMathStyle,
|
|
51
|
+
InputMathStyle,
|
|
52
|
+
OnMathPressEvent,
|
|
53
|
+
InsertMathOptions,
|
|
39
54
|
} from './EnrichedMarkdownTextInput';
|
package/src/index.web.tsx
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export { EnrichedMarkdownText, default } from './web/EnrichedMarkdownText';
|
|
2
|
-
export type {
|
|
2
|
+
export type {
|
|
3
|
+
EnrichedMarkdownTextProps,
|
|
4
|
+
LinkDecorationInfo,
|
|
5
|
+
LinkRect,
|
|
6
|
+
} from './types/MarkdownTextProps.web';
|
|
3
7
|
export type { MarkdownStyle, Md4cFlags } from './types/MarkdownStyle';
|
|
4
8
|
export type {
|
|
5
9
|
LinkPressEvent,
|
|
6
10
|
LinkLongPressEvent,
|
|
7
11
|
TaskListItemPressEvent,
|
|
12
|
+
CopyPressEvent,
|
|
8
13
|
} from './types/events';
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jest mock for `react-native-enriched-markdown-scaffold`, wired up via
|
|
3
|
+
* `jest.mock('react-native-enriched-markdown-scaffold', () => require('react-native-enriched-markdown-scaffold/jest'))`.
|
|
4
|
+
* See docs/TESTING.md for setup and the behavior it mirrors.
|
|
5
|
+
*
|
|
6
|
+
* The two components are Fabric/codegen native views: under Jest there is no
|
|
7
|
+
* native view manager, so rendering them or calling any imperative ref method
|
|
8
|
+
* (each dispatches a native command) throws. These replacements render plain RN
|
|
9
|
+
* primitives and expose every imperative method as a spy.
|
|
10
|
+
*
|
|
11
|
+
* Behavior mirrored from the native component: typing fires `onChangeText` and,
|
|
12
|
+
* when set, `onChangeMarkdown` (the raw text stands in for parsed markdown);
|
|
13
|
+
* `setValue()` updates the rendered text but emits no change events, matching
|
|
14
|
+
* the native suppression of emits for programmatic updates.
|
|
15
|
+
*
|
|
16
|
+
* The mock is typed against the real public types, so `yarn typecheck` fails if
|
|
17
|
+
* the API gains a prop or ref method the mock does not cover -- it cannot
|
|
18
|
+
* silently drift from the real component.
|
|
19
|
+
*/
|
|
20
|
+
import { useImperativeHandle, useRef, useState } from 'react';
|
|
21
|
+
import type { ComponentRef } from 'react';
|
|
22
|
+
import { Text, TextInput } from 'react-native';
|
|
23
|
+
import type {
|
|
24
|
+
CaretRect,
|
|
25
|
+
EnrichedMarkdownTextInputInstance,
|
|
26
|
+
EnrichedMarkdownTextInputProps,
|
|
27
|
+
InsertMathOptions,
|
|
28
|
+
} from '../EnrichedMarkdownTextInput';
|
|
29
|
+
import type {
|
|
30
|
+
EnrichedMarkdownTextInstance,
|
|
31
|
+
EnrichedMarkdownTextProps,
|
|
32
|
+
} from '../native/EnrichedMarkdownText';
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
DEFAULT_ACCESSIBILITY_LABELS,
|
|
36
|
+
resolveAccessibilityLabels,
|
|
37
|
+
} from '../accessibilityLabelDefaults';
|
|
38
|
+
|
|
39
|
+
type AnyFn = (...args: any[]) => any;
|
|
40
|
+
declare const jest: { fn: <T extends AnyFn>(impl?: T) => T };
|
|
41
|
+
|
|
42
|
+
const spy = <T extends AnyFn>(impl?: T): T => jest.fn(impl);
|
|
43
|
+
|
|
44
|
+
const EMPTY_CARET_RECT: CaretRect = { x: 0, y: 0, width: 0, height: 0 };
|
|
45
|
+
|
|
46
|
+
export const EnrichedMarkdownTextInput = ({
|
|
47
|
+
ref,
|
|
48
|
+
defaultValue,
|
|
49
|
+
onChangeText,
|
|
50
|
+
onChangeMarkdown,
|
|
51
|
+
onFocus,
|
|
52
|
+
onBlur,
|
|
53
|
+
editable = true,
|
|
54
|
+
placeholder,
|
|
55
|
+
placeholderTextColor,
|
|
56
|
+
autoFocus = false,
|
|
57
|
+
multiline = true,
|
|
58
|
+
scrollEnabled = true,
|
|
59
|
+
style,
|
|
60
|
+
testID,
|
|
61
|
+
accessible,
|
|
62
|
+
accessibilityLabel,
|
|
63
|
+
accessibilityHint,
|
|
64
|
+
accessibilityRole,
|
|
65
|
+
accessibilityState,
|
|
66
|
+
nativeID,
|
|
67
|
+
markdownStyle: _markdownStyle,
|
|
68
|
+
cursorColor: _cursorColor,
|
|
69
|
+
selectionColor: _selectionColor,
|
|
70
|
+
autoCapitalize: _autoCapitalize,
|
|
71
|
+
onChangeSelection: _onChangeSelection,
|
|
72
|
+
onChangeState: _onChangeState,
|
|
73
|
+
onKeyPress: _onKeyPress,
|
|
74
|
+
onCaretRectChange: _onCaretRectChange,
|
|
75
|
+
onLinkDetected: _onLinkDetected,
|
|
76
|
+
mentionIndicators: _mentionIndicators,
|
|
77
|
+
onStartMention: _onStartMention,
|
|
78
|
+
onChangeMention: _onChangeMention,
|
|
79
|
+
onEndMention: _onEndMention,
|
|
80
|
+
contextMenuItems: _contextMenuItems,
|
|
81
|
+
selectionMenuConfig: _selectionMenuConfig,
|
|
82
|
+
formatMenuConfig: _formatMenuConfig,
|
|
83
|
+
linkRegex: _linkRegex,
|
|
84
|
+
writingDirection: _writingDirection,
|
|
85
|
+
}: EnrichedMarkdownTextInputProps) => {
|
|
86
|
+
const [text, setText] = useState(defaultValue ?? '');
|
|
87
|
+
const textRef = useRef(text);
|
|
88
|
+
const inputRef = useRef<ComponentRef<typeof TextInput> | null>(null);
|
|
89
|
+
|
|
90
|
+
const applyText = (next: string) => {
|
|
91
|
+
textRef.current = next;
|
|
92
|
+
setText(next);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const handleChangeText = (next: string) => {
|
|
96
|
+
applyText(next);
|
|
97
|
+
onChangeText?.(next);
|
|
98
|
+
onChangeMarkdown?.(next);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const instanceRef = useRef<EnrichedMarkdownTextInputInstance | null>(null);
|
|
102
|
+
if (instanceRef.current === null) {
|
|
103
|
+
instanceRef.current = {
|
|
104
|
+
focus: spy(() => inputRef.current?.focus()),
|
|
105
|
+
blur: spy(() => inputRef.current?.blur()),
|
|
106
|
+
measure: spy((callback) => callback(0, 0, 0, 0, 0, 0)),
|
|
107
|
+
measureInWindow: spy((callback) => callback(0, 0, 0, 0)),
|
|
108
|
+
measureLayout: spy((_relativeToNativeNode, onSuccess) =>
|
|
109
|
+
onSuccess(0, 0, 0, 0)
|
|
110
|
+
),
|
|
111
|
+
setValue: spy((markdown: string) => applyText(markdown)),
|
|
112
|
+
setSelection: spy((_start: number, _end: number) => {}),
|
|
113
|
+
toggleBold: spy(() => {}),
|
|
114
|
+
toggleItalic: spy(() => {}),
|
|
115
|
+
toggleUnderline: spy(() => {}),
|
|
116
|
+
toggleStrikethrough: spy(() => {}),
|
|
117
|
+
toggleSpoiler: spy(() => {}),
|
|
118
|
+
toggleHeading: spy((_level) => {}),
|
|
119
|
+
toggleUnorderedList: spy(() => {}),
|
|
120
|
+
toggleOrderedList: spy(() => {}),
|
|
121
|
+
indentList: spy(() => {}),
|
|
122
|
+
outdentList: spy(() => {}),
|
|
123
|
+
setLink: spy((_url: string) => {}),
|
|
124
|
+
insertLink: spy((_text: string, _url: string) => {}),
|
|
125
|
+
insertText: spy((_text: string) => {}),
|
|
126
|
+
insertMention: spy((_displayText: string, _url: string) => {}),
|
|
127
|
+
startMention: spy((_indicator: string) => {}),
|
|
128
|
+
removeLink: spy(() => {}),
|
|
129
|
+
copyToClipboard: spy(() => {}),
|
|
130
|
+
resolvePaste: spy((_text: string, _markdown?: string) => {}),
|
|
131
|
+
// Math chip commands are native-only; the mock records the call so tests can
|
|
132
|
+
// assert the API surface without a native chip implementation.
|
|
133
|
+
insertMath: spy((_latex: string, _options?: InsertMathOptions) => {}),
|
|
134
|
+
updateMath: spy(
|
|
135
|
+
(_start: number, _latex: string, _options?: InsertMathOptions) => {}
|
|
136
|
+
),
|
|
137
|
+
removeMath: spy((_start: number) => {}),
|
|
138
|
+
getMarkdown: spy(() => Promise.resolve(textRef.current)),
|
|
139
|
+
getCaretRect: spy(() => Promise.resolve(EMPTY_CARET_RECT)),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
useImperativeHandle(ref, () => instanceRef.current!);
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<TextInput
|
|
147
|
+
ref={inputRef}
|
|
148
|
+
value={text}
|
|
149
|
+
onChangeText={handleChangeText}
|
|
150
|
+
onFocus={() => onFocus?.()}
|
|
151
|
+
onBlur={() => onBlur?.()}
|
|
152
|
+
editable={editable}
|
|
153
|
+
placeholder={placeholder}
|
|
154
|
+
placeholderTextColor={placeholderTextColor}
|
|
155
|
+
autoFocus={autoFocus}
|
|
156
|
+
multiline={multiline}
|
|
157
|
+
scrollEnabled={scrollEnabled}
|
|
158
|
+
style={style}
|
|
159
|
+
testID={testID}
|
|
160
|
+
accessible={accessible}
|
|
161
|
+
accessibilityLabel={accessibilityLabel}
|
|
162
|
+
accessibilityHint={accessibilityHint}
|
|
163
|
+
accessibilityRole={accessibilityRole}
|
|
164
|
+
accessibilityState={accessibilityState}
|
|
165
|
+
nativeID={nativeID}
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const EnrichedMarkdownText = ({
|
|
171
|
+
ref,
|
|
172
|
+
markdown,
|
|
173
|
+
containerStyle,
|
|
174
|
+
testID,
|
|
175
|
+
accessible,
|
|
176
|
+
accessibilityLabel,
|
|
177
|
+
accessibilityHint,
|
|
178
|
+
accessibilityRole,
|
|
179
|
+
accessibilityState,
|
|
180
|
+
nativeID,
|
|
181
|
+
markdownStyle: _markdownStyle,
|
|
182
|
+
onLinkPress: _onLinkPress,
|
|
183
|
+
onLinkLongPress: _onLinkLongPress,
|
|
184
|
+
onTaskListItemPress: _onTaskListItemPress,
|
|
185
|
+
onSelectionChange: _onSelectionChange,
|
|
186
|
+
enableLinkPreview: _enableLinkPreview,
|
|
187
|
+
linkLongPressSelects: _linkLongPressSelects,
|
|
188
|
+
selectable: _selectable,
|
|
189
|
+
md4cFlags: _md4cFlags,
|
|
190
|
+
allowFontScaling: _allowFontScaling,
|
|
191
|
+
maxFontSizeMultiplier: _maxFontSizeMultiplier,
|
|
192
|
+
allowTrailingMargin: _allowTrailingMargin,
|
|
193
|
+
flavor: _flavor,
|
|
194
|
+
streamingAnimation: _streamingAnimation,
|
|
195
|
+
streamingConfig: _streamingConfig,
|
|
196
|
+
spoilerOverlay: _spoilerOverlay,
|
|
197
|
+
contextMenuItems: _contextMenuItems,
|
|
198
|
+
imageRequestHeaders: _imageRequestHeaders,
|
|
199
|
+
selectionMenuConfig: _selectionMenuConfig,
|
|
200
|
+
accessibilityLabels: _accessibilityLabels,
|
|
201
|
+
selectionColor: _selectionColor,
|
|
202
|
+
selectionHandleColor: _selectionHandleColor,
|
|
203
|
+
textBreakStrategy: _textBreakStrategy,
|
|
204
|
+
lineBreakStrategyIOS: _lineBreakStrategyIOS,
|
|
205
|
+
writingDirection: _writingDirection,
|
|
206
|
+
}: EnrichedMarkdownTextProps) => {
|
|
207
|
+
const instanceRef = useRef<EnrichedMarkdownTextInstance | null>(null);
|
|
208
|
+
if (instanceRef.current === null) {
|
|
209
|
+
instanceRef.current = {
|
|
210
|
+
// No native selection under Jest; the mock records the call.
|
|
211
|
+
clearSelection: spy(() => {}),
|
|
212
|
+
measure: spy((callback) => callback(0, 0, 0, 0, 0, 0)),
|
|
213
|
+
measureInWindow: spy((callback) => callback(0, 0, 0, 0)),
|
|
214
|
+
measureLayout: spy((_relativeToNativeNode, onSuccess) =>
|
|
215
|
+
onSuccess(0, 0, 0, 0)
|
|
216
|
+
),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
useImperativeHandle(ref, () => instanceRef.current!);
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<Text
|
|
224
|
+
style={containerStyle}
|
|
225
|
+
testID={testID}
|
|
226
|
+
accessible={accessible}
|
|
227
|
+
accessibilityLabel={accessibilityLabel}
|
|
228
|
+
accessibilityHint={accessibilityHint}
|
|
229
|
+
accessibilityRole={accessibilityRole}
|
|
230
|
+
accessibilityState={accessibilityState}
|
|
231
|
+
nativeID={nativeID}
|
|
232
|
+
>
|
|
233
|
+
{markdown}
|
|
234
|
+
</Text>
|
|
235
|
+
);
|
|
236
|
+
};
|