react-native-enriched-markdown-scaffold 1.0.2-scaffold.9 → 1.2.0-scaffold.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReactNativeEnrichedMarkdown.podspec +31 -10
- package/android/build.gradle +49 -12
- package/android/consumer-rules.pro +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +18 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +6 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerDelegate.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +1 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +18 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +6 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +62 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +44 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +67 -2
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +929 -178
- package/android/src/main/baseline-prof.txt +21 -22
- package/android/src/main/cpp/jni-adapter.cpp +17 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +729 -768
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +72 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +222 -8
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +65 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +191 -26
- package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/AccessibleMarkdownTextView.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/MarkdownAccessibilityHelper.kt +54 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/events/CodeBlockPressEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/ImagePressEvent.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/LatexErrorEvent.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputManager.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +101 -9
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditPipeline.kt +48 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/InputConnectionWrapper.kt +7 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MarkdownShortcutMatcher.kt +64 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputRemend.kt +44 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputEventEmitter.kt +9 -8
- package/android/src/main/java/com/swmansion/enriched/markdown/math/LatexErrorReporter.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/MarkdownASTNode.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +5 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlankLineRenderer.kt +38 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockStyleContext.kt +2 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteRenderer.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteTextRenderer.kt +55 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeBlockRenderer.kt +8 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HighlightRenderer.kt +10 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +31 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ParagraphRenderer.kt +17 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/Renderer.kt +40 -21
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/AdmonitionIcons.kt +62 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/BlockSegmentView.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/BlockquoteContainerView.kt +401 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/CodeBlockContainerView.kt +55 -16
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/ContainerNodeView.kt +164 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/MarkdownSegment.kt +21 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/RenderedSegment.kt +137 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentHeightMeasurer.kt +139 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/SegmentReconciler.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/SegmentSignature.kt +3 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentViewCreators.kt +262 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentViewFactory.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/TableContainerView.kt +100 -36
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBackgroundSpan.kt +18 -17
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBlockSpan.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/HighlightSpan.kt +60 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ImageSpan.kt +15 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineBackgroundGeometry.kt +42 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineChipPainter.kt +4 -27
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LineHeightSpan.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerDrawUtils.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/BlockquoteStyle.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkVariantEntry.kt +2 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleConfig.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/VideoStyle.kt +31 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/BorderStyleUtils.kt +86 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/EllipsizeUtils.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/EnrichedMarkdownAncestorUtils.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/FeatureFlags.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/ReadableMapExtensions.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt +227 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/PasteTextUtils.kt +34 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/HTMLGenerator.kt +50 -28
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/MarkdownExtractor.kt +16 -21
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/SpannableExtensions.kt +4 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/BlockSpacing.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/SpanFlags.kt +13 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/CodeBlockPressHost.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/ImagePressHost.kt +19 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkEvents.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLongPressMovementMethod.kt +87 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/TextViewSetup.kt +79 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/conversions.h +2 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +9 -3
- package/android/src/math/java/com/swmansion/enriched/markdown/{views → segments}/MathContainerView.kt +86 -29
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +33 -7
- package/android/src/video/java/com/swmansion/enriched/markdown/segments/VideoContainerView.kt +115 -0
- package/cpp/md4c/md4c.c +343 -236
- package/cpp/md4c/md4c.h +28 -11
- package/cpp/parser/MD4CParser.cpp +266 -4
- package/cpp/parser/MD4CParser.hpp +6 -2
- package/cpp/parser/MarkdownASTNode.hpp +4 -1
- package/cpp/wasm/ASTSerializer.cpp +6 -0
- package/cpp/wasm/md4c_wasm.cpp +5 -1
- package/docs/API_REFERENCE.md +199 -12
- package/docs/BREAKING_CHANGES.md +75 -0
- package/docs/CODE_HIGHLIGHT.md +4 -0
- package/docs/COPY_OPTIONS.md +52 -9
- package/docs/ELEMENTS_STRUCTURE.md +48 -1
- package/docs/INPUT.md +60 -3
- package/docs/LATEX_MATH.md +30 -0
- package/docs/MACOS.md +1 -1
- package/docs/MENTIONS.md +2 -2
- package/docs/STYLES.md +27 -0
- package/docs/TEXT.md +8 -0
- package/docs/WEB.md +44 -10
- package/ios/EnrichedMarkdown.mm +285 -43
- package/ios/EnrichedMarkdownText.mm +185 -23
- package/ios/attachments/ENRMImageAttachment.h +17 -2
- package/ios/attachments/ENRMImageAttachment.m +26 -28
- package/ios/attachments/ENRMMathInlineAttachment+macOS.m +10 -2
- package/ios/attachments/ENRMMathInlineAttachment.h +3 -1
- package/ios/attachments/ENRMMathInlineAttachment.m +17 -1
- package/ios/attachments/ENRMMathInlineAttachmentShared.h +3 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +62 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +44 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +67 -2
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +929 -178
- package/ios/input/ENRMInputFormatter.mm +68 -12
- package/ios/input/ENRMInputFormatterStyle.mm +9 -2
- package/ios/input/ENRMInputParser.mm +18 -0
- package/ios/input/ENRMInputRemend.mm +40 -3
- package/ios/input/ENRMMarkdownShortcutMatcher.h +39 -0
- package/ios/input/ENRMMarkdownShortcutMatcher.mm +66 -0
- package/ios/input/EnrichedMarkdownTextInput.mm +129 -1
- package/ios/internals/ENRMViewFreeMeasurement.h +45 -6
- package/ios/internals/MeasurementCache.h +20 -4
- package/ios/internals/ShadowMeasurementUtils.h +2 -0
- package/ios/math/ENRMLatexErrorCoordinator.h +27 -0
- package/ios/math/ENRMLatexErrorCoordinator.mm +75 -0
- package/ios/math/ENRMLatexErrorReporting.h +13 -0
- package/ios/math/ENRMRaTeXBridge.swift +46 -3
- package/ios/parser/ENRMMarkdownParser.h +3 -0
- package/ios/parser/ENRMMarkdownParser.mm +11 -2
- package/ios/parser/MarkdownASTNode.h +8 -1
- package/ios/parser/MarkdownASTNode.m +20 -0
- package/ios/parser/MarkdownParserBridge.mm +13 -2
- package/ios/renderer/AttributedRenderer.h +13 -1
- package/ios/renderer/AttributedRenderer.m +24 -13
- package/ios/renderer/BaselineShiftTextAttributes.h +4 -0
- package/ios/renderer/BaselineShiftTextAttributes.m +4 -0
- package/ios/renderer/BlankLineRenderer.h +4 -0
- package/ios/renderer/BlankLineRenderer.m +51 -0
- package/ios/renderer/BlockquoteRenderer.m +1 -0
- package/ios/renderer/CodeBlockRenderer.m +8 -0
- package/ios/renderer/CodeRenderer.m +5 -2
- package/ios/renderer/ENRMBlockquoteTextRenderer.h +25 -0
- package/ios/renderer/ENRMBlockquoteTextRenderer.m +48 -0
- package/ios/renderer/ENRMImageRenderer.m +1 -1
- package/ios/renderer/ENRMMathInlineRenderer.m +9 -1
- package/ios/renderer/HeadingRenderer.m +1 -0
- package/ios/renderer/HighlightRenderer.m +6 -0
- package/ios/renderer/LinkRenderer.m +1 -1
- package/ios/renderer/ListItemRenderer.m +51 -2
- package/ios/renderer/ParagraphRenderer.m +10 -3
- package/ios/renderer/RenderContext.h +16 -0
- package/ios/renderer/RenderContext.m +16 -0
- package/ios/renderer/RendererFactory.m +6 -0
- package/ios/renderer/SubscriptRenderer.m +1 -0
- package/ios/renderer/SuperscriptRenderer.m +1 -0
- package/ios/segments/ENRMAdmonitionIcons.h +31 -0
- package/ios/segments/ENRMAdmonitionIcons.m +93 -0
- package/ios/segments/ENRMBlockquoteContainerView.h +90 -0
- package/ios/segments/ENRMBlockquoteContainerView.mm +551 -0
- package/ios/{views → segments}/ENRMCodeBlockContainerView.h +9 -4
- package/ios/{views → segments}/ENRMCodeBlockContainerView.m +147 -36
- package/ios/segments/ENRMContainerNodeView.h +52 -0
- package/ios/segments/ENRMContainerNodeView.mm +201 -0
- package/ios/segments/ENRMDynamicBlockProps.h +32 -0
- package/ios/segments/ENRMDynamicBlockProps.m +15 -0
- package/ios/{views → segments}/ENRMMathContainerView.h +13 -5
- package/ios/{views → segments}/ENRMMathContainerView.m +60 -9
- package/ios/segments/ENRMSVGPath.h +21 -0
- package/ios/segments/ENRMSVGPath.m +409 -0
- package/ios/segments/ENRMSegmentHeightMeasurer.h +33 -0
- package/ios/segments/ENRMSegmentHeightMeasurer.mm +94 -0
- package/ios/segments/ENRMVideoContainerView.h +40 -0
- package/ios/segments/ENRMVideoContainerView.m +421 -0
- package/ios/{utils → segments}/RenderedMarkdownSegment.h +19 -2
- package/ios/{utils → segments}/RenderedMarkdownSegment.m +42 -1
- package/ios/segments/SegmentRenderer.h +26 -0
- package/ios/{utils → segments}/SegmentRenderer.m +46 -9
- package/ios/{views → segments}/TableContainerView.h +5 -4
- package/ios/{views → segments}/TableContainerView.m +96 -12
- package/ios/styles/StyleConfig.h +17 -0
- package/ios/styles/StyleConfig.mm +90 -0
- package/ios/utils/ENRMCodeBlockContent.mm +13 -0
- package/ios/utils/ENRMFeatureFlags.h +6 -0
- package/ios/utils/ENRMTextRenderer.h +8 -0
- package/ios/utils/ENRMTextRenderer.m +26 -10
- package/ios/utils/ENRMUIKit.h +1 -0
- package/ios/utils/FontUtils.h +2 -1
- package/ios/utils/FontUtils.m +22 -6
- package/ios/utils/LinkTapUtils.h +17 -2
- package/ios/utils/LinkTapUtils.m +44 -2
- package/ios/utils/ListMarkerDrawer.m +25 -1
- package/ios/utils/MarkdownASTSerializer.h +7 -0
- package/ios/utils/MarkdownASTSerializer.m +243 -0
- package/ios/utils/MarkdownAccessibilityElementBuilder.m +9 -67
- package/ios/utils/MarkdownExtractor.m +6 -3
- package/ios/utils/ParagraphStyleUtils.h +25 -1
- package/ios/utils/ParagraphStyleUtils.m +51 -7
- package/ios/utils/StylePropsUtils.h +60 -1
- package/ios/utils/TextViewLayoutManager.mm +57 -0
- package/lib/module/EnrichedMarkdownNativeComponent.ts +110 -4
- package/lib/module/EnrichedMarkdownTextInput.js +60 -2
- package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
- package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +12 -0
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +115 -4
- package/lib/module/admonitionDefaults.js +34 -0
- package/lib/module/admonitionDefaults.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +84 -4
- package/lib/module/jest/index.js.map +1 -1
- package/lib/module/native/EnrichedMarkdownText.js +58 -5
- package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/normalizeMarkdownShortcuts.js +31 -0
- package/lib/module/normalizeMarkdownShortcuts.js.map +1 -0
- package/lib/module/normalizeMarkdownStyle.js +15 -1
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.web.js +15 -1
- package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
- package/lib/module/styleUtils.js +15 -3
- package/lib/module/styleUtils.js.map +1 -1
- package/lib/module/utils/textInputState.js +4 -3
- package/lib/module/utils/textInputState.js.map +1 -1
- package/lib/module/utils/usePressability.js +28 -0
- package/lib/module/utils/usePressability.js.map +1 -0
- package/lib/module/web/EnrichedMarkdownText.js +19 -6
- package/lib/module/web/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/web/globalStyles.js +7 -1
- package/lib/module/web/globalStyles.js.map +1 -1
- package/lib/module/web/nativeProps.js +70 -0
- package/lib/module/web/nativeProps.js.map +1 -0
- package/lib/module/web/parseMarkdown.js +5 -3
- package/lib/module/web/parseMarkdown.js.map +1 -1
- package/lib/module/web/renderers/BlockRenderers.js +164 -8
- package/lib/module/web/renderers/BlockRenderers.js.map +1 -1
- package/lib/module/web/renderers/admonitionIcons.js +34 -0
- package/lib/module/web/renderers/admonitionIcons.js.map +1 -0
- package/lib/module/web/styles.js +30 -8
- package/lib/module/web/styles.js.map +1 -1
- package/lib/module/web/wasm/md4c.js +0 -0
- package/lib/module/web/wasm/md4c.js.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +103 -3
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +27 -3
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +11 -0
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +108 -3
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/admonitionDefaults.d.ts +10 -0
- package/lib/typescript/src/admonitionDefaults.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +1 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/jest/index.d.ts +2 -2
- package/lib/typescript/src/jest/index.d.ts.map +1 -1
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +3 -3
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownShortcuts.d.ts +7 -0
- package/lib/typescript/src/normalizeMarkdownShortcuts.d.ts.map +1 -0
- package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
- package/lib/typescript/src/styleUtils.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts +59 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +21 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.d.ts +93 -8
- package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +25 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -1
- package/lib/typescript/src/types/events.d.ts +33 -5
- package/lib/typescript/src/types/events.d.ts.map +1 -1
- package/lib/typescript/src/utils/textInputState.d.ts +5 -3
- package/lib/typescript/src/utils/textInputState.d.ts.map +1 -1
- package/lib/typescript/src/utils/usePressability.d.ts +24 -0
- package/lib/typescript/src/utils/usePressability.d.ts.map +1 -0
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts +1 -1
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/web/globalStyles.d.ts +1 -0
- package/lib/typescript/src/web/globalStyles.d.ts.map +1 -1
- package/lib/typescript/src/web/nativeProps.d.ts +34 -0
- package/lib/typescript/src/web/nativeProps.d.ts.map +1 -0
- package/lib/typescript/src/web/parseMarkdown.d.ts +1 -1
- package/lib/typescript/src/web/parseMarkdown.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/BlockRenderers.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/admonitionIcons.d.ts +5 -0
- package/lib/typescript/src/web/renderers/admonitionIcons.d.ts.map +1 -0
- package/lib/typescript/src/web/styles.d.ts +1 -0
- package/lib/typescript/src/web/styles.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +8 -2
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/postinstall.mjs +7 -0
- package/src/EnrichedMarkdownNativeComponent.ts +110 -4
- package/src/EnrichedMarkdownTextInput.tsx +101 -4
- package/src/EnrichedMarkdownTextInputNativeComponent.ts +12 -0
- package/src/EnrichedMarkdownTextNativeComponent.ts +115 -4
- package/src/admonitionDefaults.ts +58 -0
- package/src/index.tsx +5 -0
- package/src/index.web.tsx +3 -0
- package/src/jest/index.tsx +138 -5
- package/src/native/EnrichedMarkdownText.tsx +55 -3
- package/src/normalizeMarkdownShortcuts.ts +38 -0
- package/src/normalizeMarkdownStyle.ts +17 -0
- package/src/normalizeMarkdownStyle.web.ts +17 -0
- package/src/styleUtils.ts +17 -6
- package/src/types/MarkdownStyle.ts +62 -1
- package/src/types/MarkdownStyleInternal.ts +24 -0
- package/src/types/MarkdownTextProps.ts +95 -7
- package/src/types/MarkdownTextProps.web.ts +26 -0
- package/src/types/events.ts +36 -5
- package/src/utils/textInputState.ts +5 -3
- package/src/utils/usePressability.ts +34 -0
- package/src/web/EnrichedMarkdownText.tsx +36 -3
- package/src/web/globalStyles.ts +10 -0
- package/src/web/nativeProps.ts +78 -0
- package/src/web/parseMarkdown.ts +10 -2
- package/src/web/renderers/BlockRenderers.tsx +175 -6
- package/src/web/renderers/admonitionIcons.ts +37 -0
- package/src/web/styles.ts +28 -3
- package/src/web/types.ts +12 -1
- package/src/web/wasm/md4c.js +0 -0
- package/vendor-ratex.mjs +86 -17
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/DocumentRenderer.kt +0 -16
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/RenderedSegment.kt +0 -88
- package/ios/utils/SegmentRenderer.h +0 -24
- /package/ios/{views → segments}/ENRMTableGridView.h +0 -0
- /package/ios/{views → segments}/ENRMTableGridView.m +0 -0
- /package/ios/{views → segments}/ENRMTableIOSGridView.h +0 -0
- /package/ios/{views → segments}/ENRMTableIOSGridView.m +0 -0
- /package/ios/{utils → segments}/SegmentReconciler.h +0 -0
- /package/ios/{utils → segments}/SegmentReconciler.m +0 -0
- /package/ios/{utils → segments}/SegmentViewRegistry.h +0 -0
- /package/ios/{utils → segments}/SegmentViewRegistry.m +0 -0
package/ios/EnrichedMarkdown.mm
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#import "ENRMAsyncRenderCoordinator.h"
|
|
5
5
|
#import "ENRMAtomicSize.h"
|
|
6
6
|
#import "ENRMImageAttachment.h"
|
|
7
|
+
#import "ENRMLatexErrorCoordinator.h"
|
|
7
8
|
#import "ENRMMarkdownParser.h"
|
|
8
9
|
#import "ENRMTailFadeInAnimator.h"
|
|
9
10
|
#import "ENRMTextInteractionUtils.h"
|
|
@@ -18,7 +19,12 @@
|
|
|
18
19
|
#if ENRICHED_MARKDOWN_MATH
|
|
19
20
|
#import "ENRMMathContainerView.h"
|
|
20
21
|
#endif
|
|
22
|
+
#if ENRICHED_MARKDOWN_VIDEO
|
|
23
|
+
#import "ENRMVideoContainerView.h"
|
|
24
|
+
#endif
|
|
25
|
+
#import "ENRMBlockquoteContainerView.h"
|
|
21
26
|
#import "ENRMCodeBlockContainerView.h"
|
|
27
|
+
#import "ENRMDynamicBlockProps.h"
|
|
22
28
|
#import "ENRMLinkLayout.h"
|
|
23
29
|
#import "ENRMSelectionChange.h"
|
|
24
30
|
#import "ENRMSpoilerCapable.h"
|
|
@@ -35,6 +41,7 @@
|
|
|
35
41
|
#import "MarkdownExtractor.h"
|
|
36
42
|
#import "MeasurementCache.h"
|
|
37
43
|
#import "ParagraphStyleUtils.h"
|
|
44
|
+
#import "RenderContext.h"
|
|
38
45
|
#import "RenderedMarkdownSegment.h"
|
|
39
46
|
#import "RuntimeKeys.h"
|
|
40
47
|
#import "SegmentReconciler.h"
|
|
@@ -76,9 +83,11 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
76
83
|
- (void)emitLinkPress:(NSString *)url;
|
|
77
84
|
- (void)emitLinkLongPress:(NSString *)url;
|
|
78
85
|
- (void)emitLinkLayoutIfNeeded;
|
|
86
|
+
- (void)emitImagePress:(NSString *)url altText:(NSString *)altText;
|
|
79
87
|
- (void)emitTaskListItemPress:(NSInteger)index checked:(BOOL)checked text:(NSString *)text;
|
|
80
88
|
- (void)emitCopyPress:(NSString *)code language:(NSString *)language;
|
|
81
89
|
- (void)emitCopyRequest:(NSString *)source markdown:(NSString *)markdown text:(NSString *)text whole:(BOOL)whole;
|
|
90
|
+
- (void)emitCodeBlockPress:(NSString *)code language:(NSString *)language;
|
|
82
91
|
- (void)emitContextMenuItemPress:(NSString *)itemText
|
|
83
92
|
selectedText:(NSString *)selectedText
|
|
84
93
|
selectionStart:(NSUInteger)selectionStart
|
|
@@ -89,8 +98,10 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
89
98
|
ENRMMarkdownParser *_parser;
|
|
90
99
|
StyleConfig *_config;
|
|
91
100
|
ENRMMd4cFlags *_md4cFlags;
|
|
101
|
+
BOOL _isGFM;
|
|
92
102
|
NSString *_cachedMarkdown;
|
|
93
103
|
NSString *_renderedMarkdown;
|
|
104
|
+
ENRMLatexErrorCoordinator *_latexErrorCoordinator;
|
|
94
105
|
NSMutableArray<RCTUIView *> *_segmentViews;
|
|
95
106
|
NSMutableArray<NSNumber *> *_segmentSignatures;
|
|
96
107
|
ENRMSegmentViewRegistry *_segmentViewRegistry;
|
|
@@ -110,6 +121,7 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
110
121
|
BOOL _linkLongPressSelects;
|
|
111
122
|
BOOL _enableTaskListItemToggle;
|
|
112
123
|
BOOL _contextMenuHidden;
|
|
124
|
+
BOOL _enableImagePress;
|
|
113
125
|
BOOL _streamingAnimation;
|
|
114
126
|
ENRMTableStreamingMode _tableStreamingMode;
|
|
115
127
|
ENRMCodeBlockStreamingMode _codeBlockStreamingMode;
|
|
@@ -125,6 +137,8 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
125
137
|
ENRMAccessibilityLabels *_accessibilityLabels;
|
|
126
138
|
ENRMSelectionMenuLabels _selectionMenuLabels;
|
|
127
139
|
|
|
140
|
+
ENRMDynamicBlockProps *_dynamicBlockProps;
|
|
141
|
+
|
|
128
142
|
ENRMSpoilerOverlay _spoilerOverlay;
|
|
129
143
|
|
|
130
144
|
BOOL _emitLinkLayout;
|
|
@@ -164,6 +178,8 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
164
178
|
flags.latexMath = props.latexMath;
|
|
165
179
|
flags.highlight = props.highlight;
|
|
166
180
|
flags.hardSoftBreaks = props.hardSoftBreaks;
|
|
181
|
+
flags.preserveBlankLines = props.preserveBlankLines;
|
|
182
|
+
flags.admonitions = props.admonitions;
|
|
167
183
|
return flags;
|
|
168
184
|
}
|
|
169
185
|
|
|
@@ -176,8 +192,25 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
176
192
|
self.backgroundColor = [RCTUIColor clearColor];
|
|
177
193
|
_parser = [[ENRMMarkdownParser alloc] init];
|
|
178
194
|
_md4cFlags = [EnrichedMarkdown flagsFromProps:defaultProps->md4cFlags];
|
|
195
|
+
_isGFM = defaultProps->isGFM;
|
|
179
196
|
_segmentViews = [NSMutableArray array];
|
|
180
197
|
_segmentSignatures = [NSMutableArray array];
|
|
198
|
+
__weak __typeof(self) weakLatexSelf = self;
|
|
199
|
+
_latexErrorCoordinator =
|
|
200
|
+
[[ENRMLatexErrorCoordinator alloc] initWithEmit:^BOOL(NSString *source, NSString *message, BOOL displayMode) {
|
|
201
|
+
__typeof(self) strongSelf = weakLatexSelf;
|
|
202
|
+
if (!strongSelf)
|
|
203
|
+
return NO;
|
|
204
|
+
auto emitter = std::static_pointer_cast<EnrichedMarkdownEventEmitter const>(strongSelf->_eventEmitter);
|
|
205
|
+
if (!emitter)
|
|
206
|
+
return NO;
|
|
207
|
+
emitter->onLatexError({
|
|
208
|
+
.source = std::string(source.UTF8String ?: ""),
|
|
209
|
+
.message = std::string(message.UTF8String ?: ""),
|
|
210
|
+
.displayMode = displayMode ? true : false,
|
|
211
|
+
});
|
|
212
|
+
return YES;
|
|
213
|
+
}];
|
|
181
214
|
_dirtyFlags = ENRMDirtyNone;
|
|
182
215
|
[self configureSegmentViewRegistry];
|
|
183
216
|
|
|
@@ -189,6 +222,8 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
189
222
|
_selectable = YES;
|
|
190
223
|
_enableLinkPreview = YES;
|
|
191
224
|
_enableTaskListItemToggle = YES;
|
|
225
|
+
_enableImagePress = NO;
|
|
226
|
+
_dynamicBlockProps = [[ENRMDynamicBlockProps alloc] init];
|
|
192
227
|
_streamingAnimation = NO;
|
|
193
228
|
_tableStreamingMode = ENRMTableStreamingModeProgressive;
|
|
194
229
|
_codeBlockStreamingMode = ENRMCodeBlockStreamingModeProgressive;
|
|
@@ -405,7 +440,10 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
405
440
|
return view;
|
|
406
441
|
}
|
|
407
442
|
updateView:^(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
408
|
-
|
|
443
|
+
ENRMMathSegment *mathSegment = (ENRMMathSegment *)segment.mathSegment;
|
|
444
|
+
ENRMMathContainerView *mathView = (ENRMMathContainerView *)view;
|
|
445
|
+
mathView.highlighted = mathSegment.highlighted;
|
|
446
|
+
[mathView applyLatex:mathSegment.latex];
|
|
409
447
|
}]];
|
|
410
448
|
#endif
|
|
411
449
|
|
|
@@ -432,9 +470,114 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
432
470
|
[codeBlockView applyCodeBlockNode:segment.codeBlockSegment.codeBlockNode];
|
|
433
471
|
}]];
|
|
434
472
|
|
|
473
|
+
[handlers addObject:[ENRMSegmentViewHandler handlerWithKind:ENRMSegmentKindBlockquote
|
|
474
|
+
matchesView:^BOOL(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
475
|
+
return [view isKindOfClass:[ENRMBlockquoteContainerView class]];
|
|
476
|
+
}
|
|
477
|
+
createView:^RCTUIView *(ENRMRenderedSegment *segment) {
|
|
478
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
479
|
+
if (!strongSelf) {
|
|
480
|
+
return [[RCTUIView alloc] init];
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
ENRMBlockquoteContainerView *view =
|
|
484
|
+
[strongSelf createBlockquoteViewForSegment:segment.blockquoteSegment];
|
|
485
|
+
[strongSelf animateBlockViewIfNeeded:view];
|
|
486
|
+
return view;
|
|
487
|
+
}
|
|
488
|
+
updateView:^(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
489
|
+
[(ENRMBlockquoteContainerView *)view
|
|
490
|
+
applyBlockquoteNode:segment.blockquoteSegment.blockquoteNode];
|
|
491
|
+
}]];
|
|
492
|
+
|
|
493
|
+
#if ENRICHED_MARKDOWN_VIDEO
|
|
494
|
+
[handlers addObject:[ENRMSegmentViewHandler handlerWithKind:ENRMSegmentKindVideo
|
|
495
|
+
matchesView:^BOOL(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
496
|
+
return [view isKindOfClass:[ENRMVideoContainerView class]];
|
|
497
|
+
}
|
|
498
|
+
createView:^RCTUIView *(ENRMRenderedSegment *segment) {
|
|
499
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
500
|
+
if (!strongSelf) {
|
|
501
|
+
return [[RCTUIView alloc] init];
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
ENRMVideoContainerView *view =
|
|
505
|
+
[[ENRMVideoContainerView alloc] initWithConfig:strongSelf->_config];
|
|
506
|
+
view.dynamicProps = strongSelf->_dynamicBlockProps;
|
|
507
|
+
[view applyVideoNode:segment.videoSegment.videoNode];
|
|
508
|
+
[strongSelf animateBlockViewIfNeeded:view];
|
|
509
|
+
return view;
|
|
510
|
+
}
|
|
511
|
+
updateView:^(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
512
|
+
ENRMVideoContainerView *videoView = (ENRMVideoContainerView *)view;
|
|
513
|
+
[videoView applyVideoNode:segment.videoSegment.videoNode];
|
|
514
|
+
[videoView reapplyStyle];
|
|
515
|
+
}]];
|
|
516
|
+
#endif
|
|
517
|
+
|
|
435
518
|
_segmentViewRegistry = [[ENRMSegmentViewRegistry alloc] initWithHandlers:handlers];
|
|
436
519
|
}
|
|
437
520
|
|
|
521
|
+
- (ENRMBlockquoteContainerView *)createBlockquoteViewForSegment:(ENRMBlockquoteSegment *)blockquoteSegment
|
|
522
|
+
{
|
|
523
|
+
ENRMBlockquoteContainerView *view = [[ENRMBlockquoteContainerView alloc] initWithConfig:_config];
|
|
524
|
+
view.allowFontScaling = _fontScaleObserver.allowFontScaling;
|
|
525
|
+
view.lineBreakStrategy = _lineBreakStrategy;
|
|
526
|
+
view.dynamicProps = _dynamicBlockProps;
|
|
527
|
+
view.accessibilityLabels = _accessibilityLabels;
|
|
528
|
+
|
|
529
|
+
__weak EnrichedMarkdown *weakSelf = self;
|
|
530
|
+
view.onCopyPress = ^(NSString *code, NSString *language) {
|
|
531
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
532
|
+
if (strongSelf)
|
|
533
|
+
[strongSelf emitCopyPress:code language:language];
|
|
534
|
+
};
|
|
535
|
+
view.onCodeBlockPress = ^(NSString *code, NSString *language) {
|
|
536
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
537
|
+
if (strongSelf)
|
|
538
|
+
[strongSelf emitCodeBlockPress:code language:language];
|
|
539
|
+
};
|
|
540
|
+
view.onLinkPress = ^(NSString *url) {
|
|
541
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
542
|
+
if (strongSelf && url)
|
|
543
|
+
[strongSelf emitLinkPress:url];
|
|
544
|
+
};
|
|
545
|
+
view.onLinkLongPress = ^(NSString *url) {
|
|
546
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
547
|
+
if (strongSelf && url)
|
|
548
|
+
[strongSelf emitLinkLongPress:url];
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
[view applyBlockquoteNode:blockquoteSegment.blockquoteNode];
|
|
552
|
+
return view;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/// The box the segments actually live in: the component frame inset by the
|
|
556
|
+
/// `containerStyle` border and padding (`LayoutMetrics::getContentFrame`).
|
|
557
|
+
///
|
|
558
|
+
/// Yoga hands `measureContent` an available size that already excludes those
|
|
559
|
+
/// insets and then adds them back to the frame it commits, so laying the
|
|
560
|
+
/// segments out against `self.bounds` would stack them over the padding and
|
|
561
|
+
/// across the border while the space Yoga reserved for the content stays blank
|
|
562
|
+
/// at the bottom. Unlike `EnrichedMarkdownText`, the segments are attached to
|
|
563
|
+
/// the component view itself rather than to `contentView`, so nothing applies
|
|
564
|
+
/// the insets for us.
|
|
565
|
+
///
|
|
566
|
+
/// Taken from `_layoutMetrics` rather than recomputed off `self.bounds`:
|
|
567
|
+
/// `prepareForRecycle` resets the metrics but leaves the bounds behind, so the
|
|
568
|
+
/// two do not always agree. The box is empty both before the first layout
|
|
569
|
+
/// metrics arrive and when the insets consume the whole component width; neither
|
|
570
|
+
/// may fall back to `self.bounds`, which is the padded border box the segments
|
|
571
|
+
/// must not be drawn across, so an over-constrained box clamps to zero and
|
|
572
|
+
/// callers skip laying out at all.
|
|
573
|
+
- (CGRect)contentBounds
|
|
574
|
+
{
|
|
575
|
+
CGRect box = RCTCGRectFromRect(_layoutMetrics.getContentFrame());
|
|
576
|
+
box.size.width = MAX(box.size.width, 0);
|
|
577
|
+
box.size.height = MAX(box.size.height, 0);
|
|
578
|
+
return box;
|
|
579
|
+
}
|
|
580
|
+
|
|
438
581
|
- (CGSize)computeSegmentLayoutForWidth:(CGFloat)width applyFrames:(BOOL)applyFrames
|
|
439
582
|
{
|
|
440
583
|
if (_segmentViews.count == 0)
|
|
@@ -466,6 +609,10 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
466
609
|
__block CGFloat yOffset = 0.0;
|
|
467
610
|
__block CGFloat maxContentWidth = 0.0;
|
|
468
611
|
const NSUInteger lastIndex = _segmentViews.count - 1;
|
|
612
|
+
// Frames are stacked in the component's own coordinate space, so the content
|
|
613
|
+
// origin (containerStyle border + padding) shifts every segment. yOffset stays
|
|
614
|
+
// content-relative because it doubles as the measured content height.
|
|
615
|
+
const CGPoint contentOrigin = applyFrames ? [self contentBounds].origin : CGPointZero;
|
|
469
616
|
|
|
470
617
|
[_segmentViews enumerateObjectsUsingBlock:^(RCTUIView *segment, NSUInteger i, BOOL *stop) {
|
|
471
618
|
const BOOL isLast = (i == lastIndex);
|
|
@@ -497,19 +644,30 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
497
644
|
yOffset += _config.codeBlockMarginTop;
|
|
498
645
|
segmentHeight = [(ENRMCodeBlockContainerView *)segment measureHeight:width];
|
|
499
646
|
maxContentWidth = width;
|
|
647
|
+
} else if ([segment isKindOfClass:[ENRMBlockquoteContainerView class]]) {
|
|
648
|
+
yOffset += _config.blockquoteMarginTop;
|
|
649
|
+
segmentHeight = [(ENRMBlockquoteContainerView *)segment measureHeight:width];
|
|
650
|
+
maxContentWidth = width;
|
|
500
651
|
}
|
|
652
|
+
#if ENRICHED_MARKDOWN_VIDEO
|
|
653
|
+
else if ([segment isKindOfClass:[ENRMVideoContainerView class]]) {
|
|
654
|
+
yOffset += _config.videoMarginTop;
|
|
655
|
+
segmentHeight = [(ENRMVideoContainerView *)segment measureHeight:width];
|
|
656
|
+
maxContentWidth = width;
|
|
657
|
+
}
|
|
658
|
+
#endif
|
|
501
659
|
|
|
502
660
|
if (applyFrames) {
|
|
503
|
-
CGFloat segmentX =
|
|
661
|
+
CGFloat segmentX = contentOrigin.x;
|
|
504
662
|
CGFloat segmentWidth = width;
|
|
505
663
|
if (isTable) {
|
|
506
664
|
CGFloat overhang = MAX(_config.tableHorizontalOverflow, 0);
|
|
507
665
|
if (overhang > 0) {
|
|
508
|
-
segmentX = -overhang;
|
|
666
|
+
segmentX = contentOrigin.x - overhang;
|
|
509
667
|
segmentWidth = width + overhang * 2;
|
|
510
668
|
}
|
|
511
669
|
}
|
|
512
|
-
CGRect segmentFrame = CGRectMake(segmentX, yOffset, segmentWidth, segmentHeight);
|
|
670
|
+
CGRect segmentFrame = CGRectMake(segmentX, contentOrigin.y + yOffset, segmentWidth, segmentHeight);
|
|
513
671
|
segment.frame = segmentFrame;
|
|
514
672
|
#if TARGET_OS_OSX
|
|
515
673
|
if ([segment isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
@@ -534,7 +692,14 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
534
692
|
#endif
|
|
535
693
|
else if ([segment isKindOfClass:[ENRMCodeBlockContainerView class]] && shouldAddBottomMargin) {
|
|
536
694
|
yOffset += _config.codeBlockMarginBottom;
|
|
695
|
+
} else if ([segment isKindOfClass:[ENRMBlockquoteContainerView class]] && shouldAddBottomMargin) {
|
|
696
|
+
yOffset += _config.blockquoteMarginBottom;
|
|
537
697
|
}
|
|
698
|
+
#if ENRICHED_MARKDOWN_VIDEO
|
|
699
|
+
else if ([segment isKindOfClass:[ENRMVideoContainerView class]] && shouldAddBottomMargin) {
|
|
700
|
+
yOffset += _config.videoMarginBottom;
|
|
701
|
+
}
|
|
702
|
+
#endif
|
|
538
703
|
}];
|
|
539
704
|
|
|
540
705
|
return CGSizeMake(maxContentWidth, yOffset);
|
|
@@ -593,15 +758,21 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
593
758
|
}
|
|
594
759
|
}
|
|
595
760
|
|
|
596
|
-
///
|
|
597
|
-
///
|
|
598
|
-
///
|
|
761
|
+
/// Publishes the committed size to the streaming fast path's mailbox, and picks
|
|
762
|
+
/// up the Yoga-resolved direction inherited from any ancestor `direction` style.
|
|
763
|
+
/// In FirstStrong mode the direction feeds the neutral-paragraph fallback, so a
|
|
764
|
+
/// change requires segment recreation.
|
|
765
|
+
///
|
|
766
|
+
/// The mailbox holds a content size, not the border box: `measureContent`
|
|
767
|
+
/// returns it straight to Yoga, which adds the `containerStyle` insets back on
|
|
768
|
+
/// top of whatever it gets, so storing `frame.size` would double-count them.
|
|
599
769
|
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
|
|
600
770
|
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
601
771
|
{
|
|
602
772
|
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
603
773
|
|
|
604
|
-
|
|
774
|
+
const auto contentSize = layoutMetrics.getContentFrame().size;
|
|
775
|
+
_lastCommittedSize.store(CGSizeMake(contentSize.width, contentSize.height));
|
|
605
776
|
|
|
606
777
|
NSWritingDirection resolved = _resolvedLayoutDirection;
|
|
607
778
|
if (layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
|
|
@@ -638,6 +809,8 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
638
809
|
((EnrichedMarkdownInternalText *)segment).accessibilityLabels = _accessibilityLabels;
|
|
639
810
|
} else if ([segment isKindOfClass:[TableContainerView class]]) {
|
|
640
811
|
((TableContainerView *)segment).accessibilityLabels = _accessibilityLabels;
|
|
812
|
+
} else if ([segment isKindOfClass:[ENRMBlockquoteContainerView class]]) {
|
|
813
|
+
((ENRMBlockquoteContainerView *)segment).accessibilityLabels = _accessibilityLabels;
|
|
641
814
|
}
|
|
642
815
|
#if ENRICHED_MARKDOWN_MATH
|
|
643
816
|
else if ([segment isKindOfClass:[ENRMMathContainerView class]]) {
|
|
@@ -668,32 +841,30 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
668
841
|
};
|
|
669
842
|
}
|
|
670
843
|
|
|
671
|
-
// Table, math and code block views cache
|
|
672
|
-
// creation time, so re-push them on prop updates
|
|
673
|
-
//
|
|
844
|
+
// Table, math and code block views cache `contextMenuHidden` and the menu
|
|
845
|
+
// options at creation time, so re-push them on prop updates to avoid stale
|
|
846
|
+
// values. Copy labels are no longer pushed: they live on the shared
|
|
847
|
+
// _dynamicBlockProps (upstream #708/#768) and are read live at menu-open.
|
|
848
|
+
// NOTE (merge v1.1.1, P1): this only reaches top-level segments. Blocks nested
|
|
849
|
+
// in an ENRMBlockquoteContainerView keep the defaults until P2 (I2) moves this
|
|
850
|
+
// state into ENRMDynamicBlockProps and removes this push.
|
|
674
851
|
- (void)pushSelectionMenuLabelsToSegments
|
|
675
852
|
{
|
|
676
853
|
for (RCTUIView *segment in _segmentViews) {
|
|
677
854
|
if ([segment isKindOfClass:[TableContainerView class]]) {
|
|
678
855
|
TableContainerView *tableView = (TableContainerView *)segment;
|
|
679
|
-
tableView.copyLabel = _selectionMenuLabels.copyLabel;
|
|
680
|
-
tableView.copyAsMarkdownLabel = _selectionMenuLabels.copyAsMarkdownLabel;
|
|
681
856
|
tableView.contextMenuHidden = _contextMenuHidden;
|
|
682
857
|
tableView.menuOptions = [self blockMenuOptions];
|
|
683
858
|
}
|
|
684
859
|
#if ENRICHED_MARKDOWN_MATH
|
|
685
860
|
else if ([segment isKindOfClass:[ENRMMathContainerView class]]) {
|
|
686
861
|
ENRMMathContainerView *mathView = (ENRMMathContainerView *)segment;
|
|
687
|
-
mathView.copyLabel = _selectionMenuLabels.copyLabel;
|
|
688
|
-
mathView.copyAsMarkdownLabel = _selectionMenuLabels.copyAsMarkdownLabel;
|
|
689
862
|
mathView.contextMenuHidden = _contextMenuHidden;
|
|
690
863
|
mathView.menuOptions = [self blockMenuOptions];
|
|
691
864
|
}
|
|
692
865
|
#endif
|
|
693
866
|
else if ([segment isKindOfClass:[ENRMCodeBlockContainerView class]]) {
|
|
694
867
|
ENRMCodeBlockContainerView *codeBlockView = (ENRMCodeBlockContainerView *)segment;
|
|
695
|
-
codeBlockView.copyLabel = _selectionMenuLabels.copyLabel;
|
|
696
|
-
codeBlockView.copyAsMarkdownLabel = _selectionMenuLabels.copyAsMarkdownLabel;
|
|
697
868
|
codeBlockView.contextMenuHidden = _contextMenuHidden;
|
|
698
869
|
codeBlockView.menuOptions = [self blockMenuOptions];
|
|
699
870
|
}
|
|
@@ -715,10 +886,11 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
715
886
|
MeasurementCache::shared().removeMatchingMarkdown(std::string(_renderedMarkdown.UTF8String));
|
|
716
887
|
}
|
|
717
888
|
|
|
718
|
-
|
|
889
|
+
CGRect contentBounds = [self contentBounds];
|
|
890
|
+
if (contentBounds.size.width > 0) {
|
|
719
891
|
[self setNeedsLayout];
|
|
720
|
-
CGSize measured = [self measureSize:
|
|
721
|
-
if (needsHeightUpdate(measured,
|
|
892
|
+
CGSize measured = [self measureSize:contentBounds.size.width];
|
|
893
|
+
if (needsHeightUpdate(measured, contentBounds)) {
|
|
722
894
|
[self requestHeightUpdate];
|
|
723
895
|
}
|
|
724
896
|
}
|
|
@@ -734,6 +906,7 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
734
906
|
StyleConfig *config = [_config copy];
|
|
735
907
|
ENRMMarkdownParser *parser = _parser;
|
|
736
908
|
ENRMMd4cFlags *md4cFlags = [_md4cFlags copy];
|
|
909
|
+
BOOL isGFM = _isGFM;
|
|
737
910
|
|
|
738
911
|
BOOL allowFontScaling = _fontScaleObserver.allowFontScaling;
|
|
739
912
|
CGFloat maxFontSizeMultiplier = _maxFontSizeMultiplier;
|
|
@@ -761,12 +934,13 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
761
934
|
return YES;
|
|
762
935
|
}
|
|
763
936
|
|
|
764
|
-
MarkdownASTNode *ast = [parser parseMarkdown:renderableMarkdown flags:md4cFlags];
|
|
937
|
+
MarkdownASTNode *ast = [parser parseMarkdown:renderableMarkdown flags:md4cFlags isGFM:isGFM];
|
|
765
938
|
if (!ast)
|
|
766
939
|
return NO;
|
|
767
940
|
|
|
768
941
|
renderedSegments = ENRMRenderSegmentsFromAST(ast, config, allowTrailingMargin, allowFontScaling,
|
|
769
|
-
maxFontSizeMultiplier, lineBreakStrategy
|
|
942
|
+
maxFontSizeMultiplier, lineBreakStrategy,
|
|
943
|
+
/*blockquoteContent*/ NO);
|
|
770
944
|
for (ENRMRenderedSegment *segment in renderedSegments) {
|
|
771
945
|
if (segment.kind == ENRMSegmentKindText && segment.textResult) {
|
|
772
946
|
ENRMApplyWritingDirectionMode(segment.textResult.attributedText, writingDirectionMode,
|
|
@@ -785,14 +959,14 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
785
959
|
|
|
786
960
|
- (NSArray *)parseAndRenderSegments:(NSString *)markdownString
|
|
787
961
|
{
|
|
788
|
-
MarkdownASTNode *ast = [_parser parseMarkdown:markdownString flags:_md4cFlags];
|
|
962
|
+
MarkdownASTNode *ast = [_parser parseMarkdown:markdownString flags:_md4cFlags isGFM:_isGFM];
|
|
789
963
|
if (!ast) {
|
|
790
964
|
return nil;
|
|
791
965
|
}
|
|
792
966
|
|
|
793
967
|
NSArray<ENRMRenderedSegment *> *segments =
|
|
794
968
|
ENRMRenderSegmentsFromAST(ast, _config, _allowTrailingMargin, _fontScaleObserver.allowFontScaling,
|
|
795
|
-
_maxFontSizeMultiplier, _lineBreakStrategy);
|
|
969
|
+
_maxFontSizeMultiplier, _lineBreakStrategy, /*blockquoteContent*/ NO);
|
|
796
970
|
for (ENRMRenderedSegment *segment in segments) {
|
|
797
971
|
if (segment.kind == ENRMSegmentKindText && segment.textResult) {
|
|
798
972
|
ENRMApplyWritingDirectionMode(segment.textResult.attributedText, _writingDirectionMode, _resolvedLayoutDirection);
|
|
@@ -893,16 +1067,17 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
893
1067
|
}
|
|
894
1068
|
}];
|
|
895
1069
|
|
|
896
|
-
|
|
1070
|
+
CGRect contentBounds = [self contentBounds];
|
|
1071
|
+
if (contentBounds.size.width > 0) {
|
|
897
1072
|
[self setNeedsLayout];
|
|
898
1073
|
|
|
899
1074
|
if (forceHeightUpdate || segmentTopologyChanged) {
|
|
900
|
-
[self computeSegmentLayoutForWidth:
|
|
1075
|
+
[self computeSegmentLayoutForWidth:contentBounds.size.width applyFrames:YES];
|
|
901
1076
|
[self layoutIfNeeded];
|
|
902
1077
|
[self requestHeightUpdate];
|
|
903
1078
|
} else {
|
|
904
|
-
CGSize measured = [self measureSize:
|
|
905
|
-
if (needsHeightUpdate(measured,
|
|
1079
|
+
CGSize measured = [self measureSize:contentBounds.size.width];
|
|
1080
|
+
if (needsHeightUpdate(measured, contentBounds)) {
|
|
906
1081
|
[self requestHeightUpdate];
|
|
907
1082
|
}
|
|
908
1083
|
}
|
|
@@ -917,6 +1092,7 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
917
1092
|
view.accessibilityInfo = segment.accessibilityInfo;
|
|
918
1093
|
view.accessibilityLabels = _accessibilityLabels;
|
|
919
1094
|
view.textView.selectable = _selectable;
|
|
1095
|
+
[_latexErrorCoordinator wireReporters:segment.context.mathReporters];
|
|
920
1096
|
[view applyAttributedText:segment.attributedText context:segment.context];
|
|
921
1097
|
|
|
922
1098
|
const auto &selectionProps = *std::static_pointer_cast<EnrichedMarkdownProps const>(self->_props);
|
|
@@ -954,7 +1130,7 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
954
1130
|
selectionEnd:selectionEnd];
|
|
955
1131
|
});
|
|
956
1132
|
return buildEditMenuForSelection(textView.textStorage, textView.selectedRange, segmentMarkdown, strongSelf->_config,
|
|
957
|
-
@[ baseMenu ], customItems, strongSelf->_selectionMenuConfig);
|
|
1133
|
+
@[ baseMenu ], customItems, strongSelf -> _selectionMenuConfig);
|
|
958
1134
|
}];
|
|
959
1135
|
#endif
|
|
960
1136
|
|
|
@@ -968,11 +1144,10 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
968
1144
|
tableView.allowFontScaling = _fontScaleObserver.allowFontScaling;
|
|
969
1145
|
tableView.maxFontSizeMultiplier = _maxFontSizeMultiplier;
|
|
970
1146
|
tableView.enableLinkPreview = _enableLinkPreview;
|
|
1147
|
+
tableView.dynamicProps = _dynamicBlockProps;
|
|
971
1148
|
tableView.writingDirectionMode = _writingDirectionMode;
|
|
972
1149
|
tableView.resolvedLayoutDirection = _resolvedLayoutDirection;
|
|
973
1150
|
tableView.accessibilityLabels = _accessibilityLabels;
|
|
974
|
-
tableView.copyLabel = _selectionMenuLabels.copyLabel;
|
|
975
|
-
tableView.copyAsMarkdownLabel = _selectionMenuLabels.copyAsMarkdownLabel;
|
|
976
1151
|
tableView.contextMenuHidden = _contextMenuHidden;
|
|
977
1152
|
tableView.menuOptions = [self blockMenuOptions];
|
|
978
1153
|
tableView.onCopyRequest = [self blockCopyRequestForSource:@"table"];
|
|
@@ -1013,13 +1188,17 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
1013
1188
|
- (ENRMMathContainerView *)createMathViewForSegment:(ENRMMathSegment *)mathSegment
|
|
1014
1189
|
{
|
|
1015
1190
|
ENRMMathContainerView *mathView = [[ENRMMathContainerView alloc] initWithConfig:_config];
|
|
1191
|
+
mathView.dynamicProps = _dynamicBlockProps;
|
|
1016
1192
|
mathView.accessibilityLabels = _accessibilityLabels;
|
|
1017
|
-
mathView.copyLabel = _selectionMenuLabels.copyLabel;
|
|
1018
|
-
mathView.copyAsMarkdownLabel = _selectionMenuLabels.copyAsMarkdownLabel;
|
|
1019
1193
|
mathView.contextMenuHidden = _contextMenuHidden;
|
|
1020
1194
|
mathView.menuOptions = [self blockMenuOptions];
|
|
1021
1195
|
mathView.onCopyRequest = [self blockCopyRequestForSource:@"math"];
|
|
1022
1196
|
mathView.onMenuSuppressed = [self blockMenuSuppressedForSource:@"math" view:mathView];
|
|
1197
|
+
ENRMLatexErrorCoordinator *coordinator = _latexErrorCoordinator;
|
|
1198
|
+
mathView.onLatexError = ^(NSString *source, NSString *message, BOOL displayMode) {
|
|
1199
|
+
[coordinator reportSource:source message:message displayMode:displayMode];
|
|
1200
|
+
};
|
|
1201
|
+
mathView.highlighted = mathSegment.highlighted;
|
|
1023
1202
|
[mathView applyLatex:mathSegment.latex];
|
|
1024
1203
|
return mathView;
|
|
1025
1204
|
}
|
|
@@ -1028,8 +1207,7 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
1028
1207
|
- (ENRMCodeBlockContainerView *)createCodeBlockViewForSegment:(ENRMCodeBlockSegment *)codeBlockSegment
|
|
1029
1208
|
{
|
|
1030
1209
|
ENRMCodeBlockContainerView *codeBlockView = [[ENRMCodeBlockContainerView alloc] initWithConfig:_config];
|
|
1031
|
-
codeBlockView.
|
|
1032
|
-
codeBlockView.copyAsMarkdownLabel = _selectionMenuLabels.copyAsMarkdownLabel;
|
|
1210
|
+
codeBlockView.dynamicProps = _dynamicBlockProps;
|
|
1033
1211
|
codeBlockView.contextMenuHidden = _contextMenuHidden;
|
|
1034
1212
|
codeBlockView.menuOptions = [self blockMenuOptions];
|
|
1035
1213
|
codeBlockView.onCopyRequest = [self blockCopyRequestForSource:@"code"];
|
|
@@ -1041,6 +1219,11 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
1041
1219
|
if (strongSelf)
|
|
1042
1220
|
[strongSelf emitCopyPress:code language:language];
|
|
1043
1221
|
};
|
|
1222
|
+
codeBlockView.onCodeBlockPress = ^(NSString *code, NSString *language) {
|
|
1223
|
+
EnrichedMarkdown *strongSelf = weakSelf;
|
|
1224
|
+
if (strongSelf)
|
|
1225
|
+
[strongSelf emitCodeBlockPress:code language:language];
|
|
1226
|
+
};
|
|
1044
1227
|
|
|
1045
1228
|
codeBlockView.pending = codeBlockSegment == _pendingCodeBlockSegment;
|
|
1046
1229
|
[codeBlockView applyCodeBlockNode:codeBlockSegment.codeBlockNode];
|
|
@@ -1085,7 +1268,11 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
1085
1268
|
- (void)layoutSubviews
|
|
1086
1269
|
{
|
|
1087
1270
|
[super layoutSubviews];
|
|
1088
|
-
|
|
1271
|
+
// Upstream #909: lay segments out inside the containerStyle content box.
|
|
1272
|
+
CGFloat contentWidth = [self contentBounds].size.width;
|
|
1273
|
+
if (contentWidth > 0) {
|
|
1274
|
+
[self computeSegmentLayoutForWidth:contentWidth applyFrames:YES];
|
|
1275
|
+
}
|
|
1089
1276
|
[self emitLinkLayoutIfNeeded];
|
|
1090
1277
|
// Segments may have moved or been replaced; re-read the selection (deduplicated).
|
|
1091
1278
|
[_selectionReporter schedule];
|
|
@@ -1107,7 +1294,6 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
1107
1294
|
}
|
|
1108
1295
|
|
|
1109
1296
|
if (applyMarkdownStyleToConfig(_config, newViewProps.markdownStyle, oldViewProps.markdownStyle)) {
|
|
1110
|
-
[ENRMImageAttachment clearAttachmentRegistry];
|
|
1111
1297
|
_dirtyFlags |= ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
1112
1298
|
if (!markdownChanged) {
|
|
1113
1299
|
_dirtyFlags |= ENRMDirtyRecreateSegments;
|
|
@@ -1167,15 +1353,30 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
1167
1353
|
newViewProps.md4cFlags.subscript != oldViewProps.md4cFlags.subscript ||
|
|
1168
1354
|
newViewProps.md4cFlags.latexMath != oldViewProps.md4cFlags.latexMath ||
|
|
1169
1355
|
newViewProps.md4cFlags.highlight != oldViewProps.md4cFlags.highlight ||
|
|
1170
|
-
newViewProps.md4cFlags.hardSoftBreaks != oldViewProps.md4cFlags.hardSoftBreaks
|
|
1356
|
+
newViewProps.md4cFlags.hardSoftBreaks != oldViewProps.md4cFlags.hardSoftBreaks ||
|
|
1357
|
+
newViewProps.md4cFlags.preserveBlankLines != oldViewProps.md4cFlags.preserveBlankLines ||
|
|
1358
|
+
newViewProps.md4cFlags.admonitions != oldViewProps.md4cFlags.admonitions) {
|
|
1171
1359
|
_md4cFlags = [EnrichedMarkdown flagsFromProps:newViewProps.md4cFlags];
|
|
1172
1360
|
_dirtyFlags |= ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
1173
1361
|
}
|
|
1174
1362
|
|
|
1363
|
+
if (newViewProps.isGFM != oldViewProps.isGFM) {
|
|
1364
|
+
_isGFM = newViewProps.isGFM;
|
|
1365
|
+
_dirtyFlags |= ENRMDirtyRecreateSegments | ENRMDirtyForceHeight | ENRMDirtyRender;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1175
1368
|
_enableLinkPreview = newViewProps.enableLinkPreview;
|
|
1176
1369
|
_linkLongPressSelects = newViewProps.linkLongPressSelects;
|
|
1177
1370
|
_enableTaskListItemToggle = newViewProps.enableTaskListItemToggle;
|
|
1178
1371
|
_contextMenuHidden = newViewProps.contextMenuHidden;
|
|
1372
|
+
_enableImagePress = newViewProps.enableImagePress;
|
|
1373
|
+
|
|
1374
|
+
// Block gates: mutate the shared box in place. Every existing and future block
|
|
1375
|
+
// view reads it live at use-time, so no push into segments is needed.
|
|
1376
|
+
// (`contextMenuHidden` is still pushed per view by pushSelectionMenuLabelsToSegments
|
|
1377
|
+
// below and wins over enableBlockContextMenu, merge decision D1.)
|
|
1378
|
+
_dynamicBlockProps.enableBlockContextMenu = newViewProps.enableBlockContextMenu;
|
|
1379
|
+
_dynamicBlockProps.enableCodeBlockPress = newViewProps.enableCodeBlockPress;
|
|
1179
1380
|
|
|
1180
1381
|
if (newViewProps.streamingAnimation != oldViewProps.streamingAnimation) {
|
|
1181
1382
|
_streamingAnimation = newViewProps.streamingAnimation;
|
|
@@ -1215,6 +1416,10 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
1215
1416
|
|
|
1216
1417
|
_selectionMenuLabels = ENRMParseSelectionMenuLabels(newViewProps.selectionMenuConfig);
|
|
1217
1418
|
_selectionMenuConfig = ENRMBuildSelectionMenuConfig(_selectionMenuLabels, newViewProps.selectionMenuConfig);
|
|
1419
|
+
// Block menu labels live in the shared box; block views read them live at
|
|
1420
|
+
// menu-open. (_selectionMenuLabels also feeds the text selection menu above.)
|
|
1421
|
+
_dynamicBlockProps.copyLabel = _selectionMenuLabels.copyLabel;
|
|
1422
|
+
_dynamicBlockProps.copyAsMarkdownLabel = _selectionMenuLabels.copyAsMarkdownLabel;
|
|
1218
1423
|
[self pushSelectionMenuLabelsToSegments];
|
|
1219
1424
|
|
|
1220
1425
|
if (ENRMAccessibilityLabelsChanged(oldViewProps.accessibilityLabels, newViewProps.accessibilityLabels)) {
|
|
@@ -1299,9 +1504,12 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
1299
1504
|
}
|
|
1300
1505
|
}
|
|
1301
1506
|
|
|
1302
|
-
|
|
1303
|
-
if (
|
|
1304
|
-
[self
|
|
1507
|
+
CGRect contentBounds = [self contentBounds];
|
|
1508
|
+
if (contentBounds.size.width > 0) {
|
|
1509
|
+
CGSize measured = [self measureSize:contentBounds.size.width];
|
|
1510
|
+
if (needsHeightUpdate(measured, contentBounds)) {
|
|
1511
|
+
[self requestHeightUpdate];
|
|
1512
|
+
}
|
|
1305
1513
|
}
|
|
1306
1514
|
}
|
|
1307
1515
|
}
|
|
@@ -1337,6 +1545,7 @@ static char kENRMSegmentFadeAnimatorKey;
|
|
|
1337
1545
|
_selectionOwner = nil;
|
|
1338
1546
|
[self clearActiveBlock];
|
|
1339
1547
|
_md4cFlags = [EnrichedMarkdown flagsFromProps:resetProps->md4cFlags];
|
|
1548
|
+
_isGFM = resetProps->isGFM;
|
|
1340
1549
|
_maxFontSizeMultiplier = 0;
|
|
1341
1550
|
_allowTrailingMargin = NO;
|
|
1342
1551
|
_streamingAnimation = NO;
|
|
@@ -1413,7 +1622,7 @@ Class<RCTComponentViewProtocol> EnrichedMarkdownCls(void)
|
|
|
1413
1622
|
BOOL isInsideView = CGRectContainsPoint(textSegment.textView.bounds, segmentPoint);
|
|
1414
1623
|
#endif
|
|
1415
1624
|
if (isInsideView) {
|
|
1416
|
-
if (isPointOnInteractiveElement(textSegment.textView, segmentPoint)) {
|
|
1625
|
+
if (isPointOnInteractiveElement(textSegment.textView, segmentPoint, _enableImagePress, NO)) {
|
|
1417
1626
|
return nil;
|
|
1418
1627
|
}
|
|
1419
1628
|
break;
|
|
@@ -1450,6 +1659,9 @@ Class<RCTComponentViewProtocol> EnrichedMarkdownCls(void)
|
|
|
1450
1659
|
/// JS for `renderLinkDecoration`. Tables are skipped: their cells scroll
|
|
1451
1660
|
/// horizontally, so rects would go stale. Runs after each segment layout pass;
|
|
1452
1661
|
/// deduplicated so an unchanged layout sends nothing.
|
|
1662
|
+
/// TODO(merge v1.1.1, P2/I2): links inside ENRMBlockquoteContainerView segments
|
|
1663
|
+
/// (upstream #763) are neither reported nor counted, so linkIndex of every link
|
|
1664
|
+
/// after a blockquote is off. Recurse into the container in root coordinates.
|
|
1453
1665
|
- (void)emitLinkLayoutIfNeeded
|
|
1454
1666
|
{
|
|
1455
1667
|
if (!_emitLinkLayout || self.bounds.size.width <= 0)
|
|
@@ -1480,6 +1692,13 @@ Class<RCTComponentViewProtocol> EnrichedMarkdownCls(void)
|
|
|
1480
1692
|
emitter->onLinkLayout(ENRMLinkLayoutEventFromFragments<EnrichedMarkdownEventEmitter::OnLinkLayout>(fragments));
|
|
1481
1693
|
}
|
|
1482
1694
|
|
|
1695
|
+
- (void)emitImagePress:(NSString *)url altText:(NSString *)altText
|
|
1696
|
+
{
|
|
1697
|
+
auto emitter = std::static_pointer_cast<EnrichedMarkdownEventEmitter const>(_eventEmitter);
|
|
1698
|
+
if (emitter)
|
|
1699
|
+
emitter->onImagePress({.url = std::string(url.UTF8String ?: ""), .altText = std::string(altText.UTF8String ?: "")});
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1483
1702
|
- (void)emitLinkLongPress:(NSString *)url
|
|
1484
1703
|
{
|
|
1485
1704
|
auto emitter = std::static_pointer_cast<EnrichedMarkdownEventEmitter const>(_eventEmitter);
|
|
@@ -1514,6 +1733,14 @@ Class<RCTComponentViewProtocol> EnrichedMarkdownCls(void)
|
|
|
1514
1733
|
});
|
|
1515
1734
|
}
|
|
1516
1735
|
|
|
1736
|
+
- (void)emitCodeBlockPress:(NSString *)code language:(NSString *)language
|
|
1737
|
+
{
|
|
1738
|
+
auto emitter = std::static_pointer_cast<EnrichedMarkdownEventEmitter const>(_eventEmitter);
|
|
1739
|
+
if (emitter)
|
|
1740
|
+
emitter->onCodeBlockPress(
|
|
1741
|
+
{.code = std::string(code.UTF8String ?: ""), .language = std::string(language.UTF8String ?: "")});
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1517
1744
|
- (void)emitContextMenuItemPress:(NSString *)itemText
|
|
1518
1745
|
selectedText:(NSString *)selectedText
|
|
1519
1746
|
selectionStart:(NSUInteger)selectionStart
|
|
@@ -1529,6 +1756,12 @@ Class<RCTComponentViewProtocol> EnrichedMarkdownCls(void)
|
|
|
1529
1756
|
});
|
|
1530
1757
|
}
|
|
1531
1758
|
|
|
1759
|
+
- (void)updateEventEmitter:(const facebook::react::EventEmitter::Shared &)eventEmitter
|
|
1760
|
+
{
|
|
1761
|
+
[super updateEventEmitter:eventEmitter];
|
|
1762
|
+
[_latexErrorCoordinator flushPending];
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1532
1765
|
- (void)textTapped:(ENRMTapRecognizer *)recognizer
|
|
1533
1766
|
{
|
|
1534
1767
|
ENRMPlatformTextView *textView = (ENRMPlatformTextView *)recognizer.view;
|
|
@@ -1554,7 +1787,16 @@ Class<RCTComponentViewProtocol> EnrichedMarkdownCls(void)
|
|
|
1554
1787
|
}
|
|
1555
1788
|
}
|
|
1556
1789
|
|
|
1557
|
-
ENRMHandleTapOnTextView(textView, recognizer, ^(NSString *url) { [self emitLinkPress:url]; })
|
|
1790
|
+
if (ENRMHandleTapOnTextView(textView, recognizer, ^(NSString *url) { [self emitLinkPress:url]; })) {
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
if (_enableImagePress) {
|
|
1795
|
+
NSDictionary<NSString *, NSString *> *image = imageAtTapLocation(textView, recognizer);
|
|
1796
|
+
if (image) {
|
|
1797
|
+
[self emitImagePress:image[@"url"] altText:image[@"altText"]];
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1558
1800
|
}
|
|
1559
1801
|
|
|
1560
1802
|
#if !TARGET_OS_OSX
|