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
|
@@ -43,7 +43,7 @@ static UIFont *ENRMCodeBlockHeaderFont(StyleConfig *config)
|
|
|
43
43
|
|
|
44
44
|
static CGFloat ENRMCodeBlockHeaderLabelLineHeight(UIFont *headerFont)
|
|
45
45
|
{
|
|
46
|
-
return ceil(headerFont
|
|
46
|
+
return ceil(UIFontLineHeight(headerFont));
|
|
47
47
|
}
|
|
48
48
|
#else
|
|
49
49
|
static NSFont *ENRMCodeBlockHeaderFont(StyleConfig *config)
|
|
@@ -53,7 +53,7 @@ static NSFont *ENRMCodeBlockHeaderFont(StyleConfig *config)
|
|
|
53
53
|
|
|
54
54
|
static CGFloat ENRMCodeBlockHeaderLabelLineHeight(NSFont *headerFont)
|
|
55
55
|
{
|
|
56
|
-
return ceil(headerFont
|
|
56
|
+
return ceil(UIFontLineHeight(headerFont));
|
|
57
57
|
}
|
|
58
58
|
#endif
|
|
59
59
|
|
|
@@ -67,17 +67,32 @@ static NSAttributedString *ENRMCodeBlockPlainAttributedCode(NSString *code, Styl
|
|
|
67
67
|
return attributed;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
|
|
70
|
+
// Per-line height applied to the code text (see ENRMApplyCodeBlockTextAttributes):
|
|
71
|
+
// when a code block line height is configured every line fragment is exactly that
|
|
72
|
+
// tall; otherwise the font's natural line height is used.
|
|
73
|
+
static CGFloat ENRMCodeBlockPerLineHeight(StyleConfig *config)
|
|
73
74
|
{
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
CGFloat lineHeight = [config codeBlockLineHeight];
|
|
76
|
+
return lineHeight > 0 ? lineHeight : ceil(UIFontLineHeight([config codeBlockFont]));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Analytic code height: lines never wrap and each fragment is a fixed height, so
|
|
80
|
+
// the laid-out height is simply lineCount * perLineHeight. No text layout needed,
|
|
81
|
+
// which is what boundingRectWithSize used to do on the whole block.
|
|
82
|
+
static CGFloat ENRMCodeBlockCodeHeight(NSString *code, StyleConfig *config)
|
|
83
|
+
{
|
|
84
|
+
if (code.length == 0) {
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
__block NSUInteger lineCount = 0;
|
|
88
|
+
[code enumerateSubstringsInRange:NSMakeRange(0, code.length)
|
|
89
|
+
options:NSStringEnumerationByLines | NSStringEnumerationSubstringNotRequired
|
|
90
|
+
usingBlock:^(NSString *_Nullable substring, NSRange substringRange, NSRange enclosingRange,
|
|
91
|
+
BOOL *stop) { lineCount++; }];
|
|
92
|
+
if (lineCount == 0) {
|
|
93
|
+
lineCount = 1;
|
|
76
94
|
}
|
|
77
|
-
|
|
78
|
-
options:NSStringDrawingUsesLineFragmentOrigin
|
|
79
|
-
context:nil];
|
|
80
|
-
return CGSizeMake(ceil(bounds.size.width), ceil(bounds.size.height));
|
|
95
|
+
return ceil(lineCount * ENRMCodeBlockPerLineHeight(config));
|
|
81
96
|
}
|
|
82
97
|
|
|
83
98
|
// Used only to pick the scroll indicator style for the code pane, so the
|
|
@@ -109,15 +124,30 @@ static BOOL ENRMColorIsDark(RCTUIColor *color)
|
|
|
109
124
|
|
|
110
125
|
// Scrollable code pane content. Draws the attributed code unwrapped at a
|
|
111
126
|
// fixed origin; the hosting ENRMCodeBlockContainerView draws everything else.
|
|
127
|
+
//
|
|
128
|
+
// The TextKit stack (storage/layout manager/container) is built and laid out
|
|
129
|
+
// once, when attributedCode is set, then cached: drawRect: only paints the
|
|
130
|
+
// already-computed glyphs, so scrolling and redraws never re-lay-out. This is
|
|
131
|
+
// the same rendering path drawAtPoint used internally, so output is identical,
|
|
132
|
+
// but the layout is no longer thrown away on every draw. The container is
|
|
133
|
+
// unbounded (lines never wrap) with zero line-fragment padding and font leading
|
|
134
|
+
// disabled, matching the NSStringDrawing origin the block used before.
|
|
112
135
|
@interface ENRMCodeBlockContentView : RCTUIView
|
|
113
136
|
@property (nonatomic, strong, nullable) NSAttributedString *attributedCode;
|
|
114
137
|
@property (nonatomic, assign) CGPoint textOrigin;
|
|
138
|
+
// Laid-out content width, for the horizontal scroll extent. Free once the
|
|
139
|
+
// cached stack exists; no separate measurement pass.
|
|
140
|
+
@property (nonatomic, readonly) CGFloat usedWidth;
|
|
115
141
|
#if TARGET_OS_OSX
|
|
116
142
|
@property (nonatomic, copy, nullable) NSMenu * (^menuProvider)(void);
|
|
117
143
|
#endif
|
|
118
144
|
@end
|
|
119
145
|
|
|
120
|
-
@implementation ENRMCodeBlockContentView
|
|
146
|
+
@implementation ENRMCodeBlockContentView {
|
|
147
|
+
NSTextStorage *_textStorage;
|
|
148
|
+
NSLayoutManager *_layoutManager;
|
|
149
|
+
NSTextContainer *_textContainer;
|
|
150
|
+
}
|
|
121
151
|
|
|
122
152
|
#if TARGET_OS_OSX
|
|
123
153
|
- (BOOL)isFlipped
|
|
@@ -131,17 +161,50 @@ static BOOL ENRMColorIsDark(RCTUIColor *color)
|
|
|
131
161
|
}
|
|
132
162
|
#endif
|
|
133
163
|
|
|
164
|
+
- (void)setAttributedCode:(nullable NSAttributedString *)attributedCode
|
|
165
|
+
{
|
|
166
|
+
_attributedCode = attributedCode;
|
|
167
|
+
if (attributedCode.length == 0) {
|
|
168
|
+
_textStorage = nil;
|
|
169
|
+
_layoutManager = nil;
|
|
170
|
+
_textContainer = nil;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
_textStorage = [[NSTextStorage alloc] initWithAttributedString:attributedCode];
|
|
174
|
+
_layoutManager = [[NSLayoutManager alloc] init];
|
|
175
|
+
_layoutManager.usesFontLeading = NO;
|
|
176
|
+
_textContainer = [[NSTextContainer alloc] initWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
|
177
|
+
_textContainer.lineFragmentPadding = 0;
|
|
178
|
+
_textContainer.maximumNumberOfLines = 0;
|
|
179
|
+
[_layoutManager addTextContainer:_textContainer];
|
|
180
|
+
[_textStorage addLayoutManager:_layoutManager];
|
|
181
|
+
[_layoutManager ensureLayoutForTextContainer:_textContainer];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
- (CGFloat)usedWidth
|
|
185
|
+
{
|
|
186
|
+
if (!_layoutManager) {
|
|
187
|
+
return 0;
|
|
188
|
+
}
|
|
189
|
+
return ceil([_layoutManager usedRectForTextContainer:_textContainer].size.width);
|
|
190
|
+
}
|
|
191
|
+
|
|
134
192
|
- (void)drawRect:(CGRect)rect
|
|
135
193
|
{
|
|
136
|
-
if (
|
|
137
|
-
|
|
194
|
+
if (!_layoutManager) {
|
|
195
|
+
return;
|
|
138
196
|
}
|
|
197
|
+
// Only paint the glyphs intersecting the dirty rect; tall blocks skip their
|
|
198
|
+
// off-screen lines. The rect is in view space, the layout in container space.
|
|
199
|
+
CGRect boundingRect = CGRectOffset(rect, -self.textOrigin.x, -self.textOrigin.y);
|
|
200
|
+
NSRange glyphRange = [_layoutManager glyphRangeForBoundingRect:boundingRect inTextContainer:_textContainer];
|
|
201
|
+
[_layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:self.textOrigin];
|
|
139
202
|
}
|
|
140
203
|
|
|
141
204
|
@end
|
|
142
205
|
|
|
143
206
|
#if !TARGET_OS_OSX
|
|
144
|
-
@interface ENRMCodeBlockContainerView () <UIContextMenuInteractionDelegate>
|
|
207
|
+
@interface ENRMCodeBlockContainerView () <UIContextMenuInteractionDelegate, UIGestureRecognizerDelegate>
|
|
145
208
|
@end
|
|
146
209
|
#endif
|
|
147
210
|
|
|
@@ -160,21 +223,16 @@ static BOOL ENRMColorIsDark(RCTUIColor *color)
|
|
|
160
223
|
#if !TARGET_OS_OSX
|
|
161
224
|
UIFont *_headerFont;
|
|
162
225
|
UIButton *_copyButton;
|
|
226
|
+
UITapGestureRecognizer *_tapRecognizer;
|
|
163
227
|
#else
|
|
164
228
|
NSFont *_headerFont;
|
|
165
229
|
NSButton *_copyButton;
|
|
166
230
|
#endif
|
|
167
231
|
}
|
|
168
232
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
- (void)setCopyLabel:(NSString *)copyLabel
|
|
173
|
-
{
|
|
174
|
-
_copyLabel = [copyLabel copy];
|
|
175
|
-
_copyButton.accessibilityLabel = _copyLabel;
|
|
176
|
-
}
|
|
177
|
-
|
|
233
|
+
// Copy labels now live on the shared dynamicProps (upstream #708/#768); the fork's per-view
|
|
234
|
+
// copyLabel/copyAsMarkdownLabel setters are gone. The header button's macOS accessibility label
|
|
235
|
+
// is refreshed in applyCodeBlockNode:. menuOptions stays per-view (fork, pushed by the root).
|
|
178
236
|
- (void)setMenuOptions:(ENRMBlockMenuOptions)menuOptions
|
|
179
237
|
{
|
|
180
238
|
_menuOptions = menuOptions;
|
|
@@ -211,6 +269,7 @@ static BOOL ENRMColorIsDark(RCTUIColor *color)
|
|
|
211
269
|
_config = config;
|
|
212
270
|
_cachedCode = @"";
|
|
213
271
|
_fenceChar = @"`";
|
|
272
|
+
_dynamicProps = [[ENRMDynamicBlockProps alloc] init];
|
|
214
273
|
_headerFont = ENRMCodeBlockHeaderFont(config);
|
|
215
274
|
_headerLabelLineHeight = ENRMCodeBlockHeaderLabelLineHeight(_headerFont);
|
|
216
275
|
self.backgroundColor = [RCTUIColor clearColor];
|
|
@@ -232,6 +291,10 @@ static BOOL ENRMColorIsDark(RCTUIColor *color)
|
|
|
232
291
|
_copyButton.tintColor = [[config codeBlockColor] colorWithAlphaComponent:kENRMHeaderSecondaryAlpha];
|
|
233
292
|
[_copyButton addTarget:self action:@selector(copyCodeToPasteboard) forControlEvents:UIControlEventTouchUpInside];
|
|
234
293
|
[self addSubview:_copyButton];
|
|
294
|
+
|
|
295
|
+
_tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleCodeBlockTap:)];
|
|
296
|
+
_tapRecognizer.delegate = self;
|
|
297
|
+
[self addGestureRecognizer:_tapRecognizer];
|
|
235
298
|
#else
|
|
236
299
|
NSImageSymbolConfiguration *symbolConfig =
|
|
237
300
|
[NSImageSymbolConfiguration configurationWithPointSize:[config codeBlockFont].pointSize * kENRMHeaderIconScale
|
|
@@ -353,8 +416,10 @@ static BOOL ENRMColorIsDark(RCTUIColor *color)
|
|
|
353
416
|
NSAttributedString *highlighted =
|
|
354
417
|
_pending ? nil : ENRMHighlightedAttributedCode(plainCode, _cachedCode, _cachedLanguage, _config);
|
|
355
418
|
_attributedCode = highlighted ?: plainCode;
|
|
356
|
-
|
|
419
|
+
// Setting attributedCode builds and lays out the cached TextKit stack once;
|
|
420
|
+
// width then reads out of that layout, and height stays analytic.
|
|
357
421
|
_codeContentView.attributedCode = _attributedCode;
|
|
422
|
+
_codeSize = CGSizeMake(_codeContentView.usedWidth, ENRMCodeBlockCodeHeight(_cachedCode, _config));
|
|
358
423
|
}
|
|
359
424
|
|
|
360
425
|
- (void)applyCodeBlockNode:(MarkdownASTNode *)node
|
|
@@ -372,6 +437,13 @@ static BOOL ENRMColorIsDark(RCTUIColor *color)
|
|
|
372
437
|
|
|
373
438
|
[self rebuildAttributedCode];
|
|
374
439
|
|
|
440
|
+
// iOS VoiceOver reads the copy label live via accessibilityCustomActions and the
|
|
441
|
+
// button is hidden behind the container's single a11y element, so its own label
|
|
442
|
+
// is consumed only on macOS; refresh it there on each content update.
|
|
443
|
+
#if TARGET_OS_OSX
|
|
444
|
+
_copyButton.accessibilityLabel = self.dynamicProps.menuCopyLabel;
|
|
445
|
+
#endif
|
|
446
|
+
|
|
375
447
|
#if !TARGET_OS_OSX
|
|
376
448
|
[self setNeedsLayout];
|
|
377
449
|
[self setNeedsDisplay];
|
|
@@ -420,8 +492,8 @@ static BOOL ENRMColorIsDark(RCTUIColor *color)
|
|
|
420
492
|
{
|
|
421
493
|
CGFloat inset = ENRMCodeBlockContentInset(config);
|
|
422
494
|
CGFloat headerH = inset + ENRMCodeBlockHeaderLabelLineHeight(ENRMCodeBlockHeaderFont(config));
|
|
423
|
-
|
|
424
|
-
return
|
|
495
|
+
CGFloat codeHeight = ENRMCodeBlockCodeHeight(ENRMCodeBlockExtractCode(node), config);
|
|
496
|
+
return codeHeight + inset * 2 + headerH;
|
|
425
497
|
}
|
|
426
498
|
|
|
427
499
|
- (void)drawRect:(CGRect)rect
|
|
@@ -489,21 +561,60 @@ static BOOL ENRMColorIsDark(RCTUIColor *color)
|
|
|
489
561
|
copyStringToPasteboard([self fencedMarkdown]);
|
|
490
562
|
}
|
|
491
563
|
|
|
564
|
+
#if !TARGET_OS_OSX
|
|
565
|
+
- (void)handleCodeBlockTap:(UITapGestureRecognizer *)recognizer
|
|
566
|
+
{
|
|
567
|
+
if (!self.dynamicProps.enableCodeBlockPress || _pending) {
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
if (self.onCodeBlockPress) {
|
|
571
|
+
self.onCodeBlockPress(_cachedCode ?: @"", _cachedLanguage ?: @"");
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
|
|
576
|
+
{
|
|
577
|
+
if (gestureRecognizer == _tapRecognizer) {
|
|
578
|
+
return self.dynamicProps.enableCodeBlockPress && !_pending;
|
|
579
|
+
}
|
|
580
|
+
return YES;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
|
|
584
|
+
{
|
|
585
|
+
// Let the copy button handle its own tap.
|
|
586
|
+
for (UIView *hit = touch.view; hit != nil; hit = hit.superview) {
|
|
587
|
+
if (hit == _copyButton) {
|
|
588
|
+
return NO;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return YES;
|
|
592
|
+
}
|
|
593
|
+
#endif
|
|
594
|
+
|
|
492
595
|
#if !TARGET_OS_OSX
|
|
493
596
|
- (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction
|
|
494
597
|
configurationForMenuAtLocation:(CGPoint)location
|
|
495
598
|
{
|
|
496
599
|
// Returning nil is the UIKit-sanctioned way to suppress a context menu.
|
|
497
|
-
|
|
498
|
-
|
|
600
|
+
// `contextMenuHidden` (fork) wins over `enableBlockContextMenu` (upstream #708) and still
|
|
601
|
+
// reports the block through onMenuSuppressed (merge decision D1).
|
|
602
|
+
if (_pending) {
|
|
603
|
+
return nil;
|
|
604
|
+
}
|
|
605
|
+
if (self.contextMenuHidden) {
|
|
606
|
+
if (self.onMenuSuppressed) {
|
|
499
607
|
self.onMenuSuppressed([self fencedMarkdown], _cachedCode ?: @"");
|
|
500
608
|
}
|
|
501
609
|
return nil;
|
|
502
610
|
}
|
|
611
|
+
if (!self.dynamicProps.enableBlockContextMenu) {
|
|
612
|
+
return nil;
|
|
613
|
+
}
|
|
503
614
|
__weak __typeof(self) weakSelf = self;
|
|
504
615
|
return ENRMBlockContextMenuConfiguration(
|
|
505
|
-
self.menuOptions, self.
|
|
506
|
-
^{ [weakSelf copyMarkdownToPasteboard]; }, ^{ [weakSelf requestCopy]; });
|
|
616
|
+
self.menuOptions, self.dynamicProps.menuCopyLabel, self.dynamicProps.menuCopyAsMarkdownLabel,
|
|
617
|
+
^{ [weakSelf copyCodeToPasteboard]; }, ^{ [weakSelf copyMarkdownToPasteboard]; }, ^{ [weakSelf requestCopy]; });
|
|
507
618
|
}
|
|
508
619
|
|
|
509
620
|
- (void)requestCopy
|
|
@@ -519,12 +630,12 @@ static BOOL ENRMColorIsDark(RCTUIColor *color)
|
|
|
519
630
|
{
|
|
520
631
|
// Both menuForEvent: paths return this directly, so nil fully suppresses the
|
|
521
632
|
// menu rather than restoring the AppKit default.
|
|
522
|
-
if (_pending || self.contextMenuHidden) {
|
|
633
|
+
if (_pending || self.contextMenuHidden || !self.dynamicProps.enableBlockContextMenu) {
|
|
523
634
|
return nil;
|
|
524
635
|
}
|
|
525
636
|
NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
|
|
526
|
-
[menu addItem:ENRMCreateMenuItem(self.
|
|
527
|
-
[menu addItem:ENRMCreateMenuItem(self.
|
|
637
|
+
[menu addItem:ENRMCreateMenuItem(self.dynamicProps.menuCopyLabel, ^{ [self copyCodeToPasteboard]; })];
|
|
638
|
+
[menu addItem:ENRMCreateMenuItem(self.dynamicProps.menuCopyAsMarkdownLabel, ^{ [self copyMarkdownToPasteboard]; })];
|
|
528
639
|
return menu;
|
|
529
640
|
}
|
|
530
641
|
|
|
@@ -549,11 +660,11 @@ static BOOL ENRMColorIsDark(RCTUIColor *color)
|
|
|
549
660
|
// button subview from VoiceOver; expose the copy action explicitly instead.
|
|
550
661
|
- (NSArray<UIAccessibilityCustomAction *> *)accessibilityCustomActions
|
|
551
662
|
{
|
|
552
|
-
if (_pending || self.menuOptions.copyHidden || self.
|
|
663
|
+
if (_pending || self.menuOptions.copyHidden || self.dynamicProps.menuCopyLabel.length == 0) {
|
|
553
664
|
return @[];
|
|
554
665
|
}
|
|
555
666
|
UIAccessibilityCustomAction *copyAction =
|
|
556
|
-
[[UIAccessibilityCustomAction alloc] initWithName:self.
|
|
667
|
+
[[UIAccessibilityCustomAction alloc] initWithName:self.dynamicProps.menuCopyLabel
|
|
557
668
|
target:self
|
|
558
669
|
selector:@selector(performCopyAccessibilityAction:)];
|
|
559
670
|
return @[ copyAction ];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#import "ENRMUIKit.h"
|
|
4
|
+
#import "RenderedMarkdownSegment.h"
|
|
5
|
+
#import "SegmentViewRegistry.h"
|
|
6
|
+
#import "StyleConfig.h"
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Reusable host view for an AST branch node that holds a vertical stack of block
|
|
12
|
+
* children (currently every blockquote; the analogue of Android's
|
|
13
|
+
* ContainerNodeView). It owns the machinery shared by such hosts: reconciling a
|
|
14
|
+
* list of ENRMRenderedSegment into real child views by signature via
|
|
15
|
+
* ENRMSegmentReconciler + a per-kind ENRMSegmentViewRegistry the subclass
|
|
16
|
+
* supplies, stacking them vertically with per-segment margins, and reporting the
|
|
17
|
+
* total height (including its own content insets).
|
|
18
|
+
*
|
|
19
|
+
* Layout honors contentInsets so a subclass can inset its children (e.g. a
|
|
20
|
+
* blockquote's border/gap/padding): children are laid out at width minus the
|
|
21
|
+
* horizontal insets, starting at (insets.left, insets.top). Per-kind margins are
|
|
22
|
+
* read from the config exactly as the root view's layout applies them.
|
|
23
|
+
*
|
|
24
|
+
* Streaming inside a container is treated as static: no fade/tail animation and
|
|
25
|
+
* no pending-code-fence sync. A content change re-signs the whole subtree, so
|
|
26
|
+
* the outer reconciler still reuses the container view by signature.
|
|
27
|
+
*/
|
|
28
|
+
@interface ENRMContainerNodeView : RCTUIView
|
|
29
|
+
|
|
30
|
+
@property (nonatomic, strong) StyleConfig *config;
|
|
31
|
+
|
|
32
|
+
// Set by a subclass before applySegments:reset:. The reconcile/layout loop is
|
|
33
|
+
// identical across hosts; only the child view construction varies per registry.
|
|
34
|
+
@property (nonatomic, strong) ENRMSegmentViewRegistry *segmentViewRegistry;
|
|
35
|
+
|
|
36
|
+
// Inset applied to all children. A plain container leaves this zero.
|
|
37
|
+
@property (nonatomic, assign) UIEdgeInsets contentInsets;
|
|
38
|
+
|
|
39
|
+
// Whether the last child contributes its trailing bottom margin.
|
|
40
|
+
@property (nonatomic, assign) BOOL allowTrailingMargin;
|
|
41
|
+
|
|
42
|
+
// Reconciles the current child views against renderedSegments, attaching and
|
|
43
|
+
// removing subviews as needed. Requests a re-layout.
|
|
44
|
+
- (void)applySegments:(NSArray<ENRMRenderedSegment *> *)renderedSegments reset:(BOOL)reset;
|
|
45
|
+
|
|
46
|
+
// Total laid-out height for the current children at contentWidth (inner width,
|
|
47
|
+
// i.e. bounds width minus horizontal insets), including the vertical insets.
|
|
48
|
+
- (CGFloat)computeContentHeightForWidth:(CGFloat)contentWidth;
|
|
49
|
+
|
|
50
|
+
@end
|
|
51
|
+
|
|
52
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#import "ENRMContainerNodeView.h"
|
|
2
|
+
#import "ENRMBlockquoteContainerView.h"
|
|
3
|
+
#import "ENRMCodeBlockContainerView.h"
|
|
4
|
+
#import "ENRMFeatureFlags.h"
|
|
5
|
+
#import "EnrichedMarkdownInternalText.h"
|
|
6
|
+
#import "SegmentReconciler.h"
|
|
7
|
+
#import "TableContainerView.h"
|
|
8
|
+
#if ENRICHED_MARKDOWN_MATH
|
|
9
|
+
#import "ENRMMathContainerView.h"
|
|
10
|
+
#endif
|
|
11
|
+
#if ENRICHED_MARKDOWN_VIDEO
|
|
12
|
+
#import "ENRMVideoContainerView.h"
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
@implementation ENRMContainerNodeView {
|
|
16
|
+
NSMutableArray<RCTUIView *> *_segmentViews;
|
|
17
|
+
NSMutableArray<NSNumber *> *_segmentSignatures;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
21
|
+
{
|
|
22
|
+
if (self = [super initWithFrame:frame]) {
|
|
23
|
+
_segmentViews = [NSMutableArray array];
|
|
24
|
+
_segmentSignatures = [NSMutableArray array];
|
|
25
|
+
_contentInsets = UIEdgeInsetsZero;
|
|
26
|
+
_allowTrailingMargin = NO;
|
|
27
|
+
self.backgroundColor = [RCTUIColor clearColor];
|
|
28
|
+
#if !TARGET_OS_OSX
|
|
29
|
+
self.contentMode = UIViewContentModeRedraw;
|
|
30
|
+
#endif
|
|
31
|
+
}
|
|
32
|
+
return self;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#if TARGET_OS_OSX
|
|
36
|
+
- (BOOL)isFlipped
|
|
37
|
+
{
|
|
38
|
+
return YES;
|
|
39
|
+
}
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
- (void)applySegments:(NSArray<ENRMRenderedSegment *> *)renderedSegments reset:(BOOL)reset
|
|
43
|
+
{
|
|
44
|
+
ENRMSegmentViewRegistry *registry = _segmentViewRegistry;
|
|
45
|
+
ENRMSegmentReconciliationResult *result = [ENRMSegmentReconciler reconcileCurrentViews:_segmentViews
|
|
46
|
+
currentSignatures:_segmentSignatures
|
|
47
|
+
renderedSegments:renderedSegments
|
|
48
|
+
reset:reset
|
|
49
|
+
createView:^RCTUIView *(ENRMRenderedSegment *segment) { return [registry createViewForSegment:segment]; }
|
|
50
|
+
updateView:^(RCTUIView *view, ENRMRenderedSegment *segment) { [registry updateView:view withSegment:segment]; }
|
|
51
|
+
attachView:^(RCTUIView *view) { [self addSubview:view]; }
|
|
52
|
+
removeView:^(RCTUIView *view) { [view removeFromSuperview]; }
|
|
53
|
+
matchesKind:^BOOL(RCTUIView *view, ENRMRenderedSegment *segment) {
|
|
54
|
+
return [registry view:view matchesSegment:segment];
|
|
55
|
+
}];
|
|
56
|
+
|
|
57
|
+
_segmentViews = result.views;
|
|
58
|
+
_segmentSignatures = result.signatures;
|
|
59
|
+
|
|
60
|
+
#if !TARGET_OS_OSX
|
|
61
|
+
[self setNeedsLayout];
|
|
62
|
+
#else
|
|
63
|
+
self.needsLayout = YES;
|
|
64
|
+
#endif
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (CGFloat)marginTopForView:(RCTUIView *)view
|
|
68
|
+
{
|
|
69
|
+
if ([view isKindOfClass:[TableContainerView class]]) {
|
|
70
|
+
return _config.tableMarginTop;
|
|
71
|
+
}
|
|
72
|
+
if ([view isKindOfClass:[ENRMCodeBlockContainerView class]]) {
|
|
73
|
+
return _config.codeBlockMarginTop;
|
|
74
|
+
}
|
|
75
|
+
if ([view isKindOfClass:[ENRMBlockquoteContainerView class]]) {
|
|
76
|
+
// A quote laid out inside another quote is nested and carries no margin; the
|
|
77
|
+
// outermost quote's margin is applied by the root host instead.
|
|
78
|
+
return ((ENRMBlockquoteContainerView *)view).nested ? 0 : _config.blockquoteMarginTop;
|
|
79
|
+
}
|
|
80
|
+
#if ENRICHED_MARKDOWN_MATH
|
|
81
|
+
if ([view isKindOfClass:[ENRMMathContainerView class]]) {
|
|
82
|
+
return _config.mathMarginTop;
|
|
83
|
+
}
|
|
84
|
+
#endif
|
|
85
|
+
#if ENRICHED_MARKDOWN_VIDEO
|
|
86
|
+
if ([view isKindOfClass:[ENRMVideoContainerView class]]) {
|
|
87
|
+
return _config.videoMarginTop;
|
|
88
|
+
}
|
|
89
|
+
#endif
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
- (CGFloat)marginBottomForView:(RCTUIView *)view
|
|
94
|
+
{
|
|
95
|
+
if ([view isKindOfClass:[TableContainerView class]]) {
|
|
96
|
+
return _config.tableMarginBottom;
|
|
97
|
+
}
|
|
98
|
+
if ([view isKindOfClass:[ENRMCodeBlockContainerView class]]) {
|
|
99
|
+
return _config.codeBlockMarginBottom;
|
|
100
|
+
}
|
|
101
|
+
if ([view isKindOfClass:[ENRMBlockquoteContainerView class]]) {
|
|
102
|
+
return ((ENRMBlockquoteContainerView *)view).nested ? 0 : _config.blockquoteMarginBottom;
|
|
103
|
+
}
|
|
104
|
+
#if ENRICHED_MARKDOWN_MATH
|
|
105
|
+
if ([view isKindOfClass:[ENRMMathContainerView class]]) {
|
|
106
|
+
return _config.mathMarginBottom;
|
|
107
|
+
}
|
|
108
|
+
#endif
|
|
109
|
+
#if ENRICHED_MARKDOWN_VIDEO
|
|
110
|
+
if ([view isKindOfClass:[ENRMVideoContainerView class]]) {
|
|
111
|
+
return _config.videoMarginBottom;
|
|
112
|
+
}
|
|
113
|
+
#endif
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
- (CGFloat)heightForView:(RCTUIView *)view atWidth:(CGFloat)width shouldAddBottomMargin:(BOOL)shouldAddBottomMargin
|
|
118
|
+
{
|
|
119
|
+
if ([view isKindOfClass:[EnrichedMarkdownInternalText class]]) {
|
|
120
|
+
EnrichedMarkdownInternalText *textView = (EnrichedMarkdownInternalText *)view;
|
|
121
|
+
textView.allowTrailingMargin = shouldAddBottomMargin;
|
|
122
|
+
return [textView measureSize:width].height;
|
|
123
|
+
}
|
|
124
|
+
if ([view isKindOfClass:[TableContainerView class]]) {
|
|
125
|
+
return [(TableContainerView *)view measureHeight:width];
|
|
126
|
+
}
|
|
127
|
+
if ([view isKindOfClass:[ENRMCodeBlockContainerView class]]) {
|
|
128
|
+
return [(ENRMCodeBlockContainerView *)view measureHeight:width];
|
|
129
|
+
}
|
|
130
|
+
if ([view isKindOfClass:[ENRMBlockquoteContainerView class]]) {
|
|
131
|
+
return [(ENRMBlockquoteContainerView *)view measureHeight:width];
|
|
132
|
+
}
|
|
133
|
+
#if ENRICHED_MARKDOWN_MATH
|
|
134
|
+
if ([view isKindOfClass:[ENRMMathContainerView class]]) {
|
|
135
|
+
return [(ENRMMathContainerView *)view measureHeight:width];
|
|
136
|
+
}
|
|
137
|
+
#endif
|
|
138
|
+
#if ENRICHED_MARKDOWN_VIDEO
|
|
139
|
+
if ([view isKindOfClass:[ENRMVideoContainerView class]]) {
|
|
140
|
+
return [(ENRMVideoContainerView *)view measureHeight:width];
|
|
141
|
+
}
|
|
142
|
+
#endif
|
|
143
|
+
return 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Mirrors the root's computeSegmentLayoutForWidth: (text via measureSize:,
|
|
147
|
+
// block kinds via measureHeight: plus their config margins), but confined to the
|
|
148
|
+
// inner content rect defined by contentInsets so a subclass can pad its children.
|
|
149
|
+
- (CGSize)layoutChildrenForOuterWidth:(CGFloat)outerWidth applyFrames:(BOOL)applyFrames
|
|
150
|
+
{
|
|
151
|
+
CGFloat contentWidth = MAX(outerWidth - _contentInsets.left - _contentInsets.right, 0);
|
|
152
|
+
if (_segmentViews.count == 0 || contentWidth <= 0) {
|
|
153
|
+
return CGSizeMake(0, _contentInsets.top + _contentInsets.bottom);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
CGFloat yOffset = _contentInsets.top;
|
|
157
|
+
const NSUInteger lastIndex = _segmentViews.count - 1;
|
|
158
|
+
|
|
159
|
+
for (NSUInteger i = 0; i < _segmentViews.count; i++) {
|
|
160
|
+
RCTUIView *view = _segmentViews[i];
|
|
161
|
+
const BOOL isLast = (i == lastIndex);
|
|
162
|
+
const BOOL shouldAddBottomMargin = (!isLast || _allowTrailingMargin);
|
|
163
|
+
|
|
164
|
+
yOffset += [self marginTopForView:view];
|
|
165
|
+
CGFloat height = [self heightForView:view atWidth:contentWidth shouldAddBottomMargin:shouldAddBottomMargin];
|
|
166
|
+
|
|
167
|
+
if (applyFrames) {
|
|
168
|
+
view.frame = CGRectMake(_contentInsets.left, yOffset, contentWidth, height);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
yOffset += height;
|
|
172
|
+
if (shouldAddBottomMargin) {
|
|
173
|
+
yOffset += [self marginBottomForView:view];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
yOffset += _contentInsets.bottom;
|
|
178
|
+
return CGSizeMake(outerWidth, yOffset);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
- (CGFloat)computeContentHeightForWidth:(CGFloat)contentWidth
|
|
182
|
+
{
|
|
183
|
+
return [self layoutChildrenForOuterWidth:contentWidth + _contentInsets.left + _contentInsets.right applyFrames:NO]
|
|
184
|
+
.height;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
#if !TARGET_OS_OSX
|
|
188
|
+
- (void)layoutSubviews
|
|
189
|
+
{
|
|
190
|
+
[super layoutSubviews];
|
|
191
|
+
[self layoutChildrenForOuterWidth:self.bounds.size.width applyFrames:YES];
|
|
192
|
+
}
|
|
193
|
+
#else
|
|
194
|
+
- (void)layout
|
|
195
|
+
{
|
|
196
|
+
[super layout];
|
|
197
|
+
[self layoutChildrenForOuterWidth:self.bounds.size.width applyFrames:YES];
|
|
198
|
+
}
|
|
199
|
+
#endif
|
|
200
|
+
|
|
201
|
+
@end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#import <Foundation/Foundation.h>
|
|
3
|
+
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Runtime-mutable block props that a prop update can flip WITHOUT recreating the
|
|
8
|
+
* segment tree: the block context-menu gate, the code-block tap gate, and the
|
|
9
|
+
* copy menu labels. The root owns one instance and mutates it in place; every
|
|
10
|
+
* block view down the tree holds the same reference (never a copy) and reads a
|
|
11
|
+
* field at use-time (menu-open, tap). So a view created after a toggle - e.g. a
|
|
12
|
+
* code block added to a blockquote once onCodeBlockPress is on - is born current
|
|
13
|
+
* instead of from a stale snapshot, and no per-toggle push into existing views is
|
|
14
|
+
* needed. Mirrors Android's DynamicBlockProps. See issues #768 and #822.
|
|
15
|
+
*
|
|
16
|
+
* The copy/tap callbacks stay per-view: on iOS they are stable event bridges set
|
|
17
|
+
* once at creation, so they never go stale. Only props that actually change at
|
|
18
|
+
* runtime and gate no layout/draw belong here; style stays on the immutable
|
|
19
|
+
* StyleConfig, where a snapshot can never go stale.
|
|
20
|
+
*
|
|
21
|
+
* Getters are renamed to avoid the Cocoa `copy` method family, matching
|
|
22
|
+
* ENRMCodeBlockContainerView; property names are unchanged so call sites read
|
|
23
|
+
* dynamic.copyLabel.
|
|
24
|
+
*/
|
|
25
|
+
@interface ENRMDynamicBlockProps : NSObject
|
|
26
|
+
@property (nonatomic, assign) BOOL enableBlockContextMenu;
|
|
27
|
+
@property (nonatomic, assign) BOOL enableCodeBlockPress;
|
|
28
|
+
@property (nonatomic, copy, nullable, getter=menuCopyLabel) NSString *copyLabel;
|
|
29
|
+
@property (nonatomic, copy, nullable, getter=menuCopyAsMarkdownLabel) NSString *copyAsMarkdownLabel;
|
|
30
|
+
@end
|
|
31
|
+
|
|
32
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
#import "ENRMBlockMenu.h"
|
|
3
|
+
#import "ENRMDynamicBlockProps.h"
|
|
4
|
+
#import "ENRMLatexErrorReporting.h"
|
|
3
5
|
#import "ENRMUIKit.h"
|
|
4
6
|
#import "StyleConfig.h"
|
|
5
7
|
|
|
@@ -7,7 +9,7 @@
|
|
|
7
9
|
|
|
8
10
|
NS_ASSUME_NONNULL_BEGIN
|
|
9
11
|
|
|
10
|
-
@interface ENRMMathContainerView : RCTUIView
|
|
12
|
+
@interface ENRMMathContainerView : RCTUIView <ENRMLatexErrorReporting>
|
|
11
13
|
|
|
12
14
|
- (instancetype)initWithConfig:(StyleConfig *)config;
|
|
13
15
|
|
|
@@ -24,13 +26,19 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
24
26
|
+ (CGFloat)measureHeightForLatex:(NSString *)latex config:(StyleConfig *)config maxWidth:(CGFloat)maxWidth;
|
|
25
27
|
|
|
26
28
|
@property (nonatomic, strong) StyleConfig *config;
|
|
29
|
+
|
|
30
|
+
/// A `==$$…$$==` block: the formula's own frame takes the highlight background
|
|
31
|
+
/// and the formula the highlight colour. Set it before `applyLatex:`; a change
|
|
32
|
+
/// afterwards parses the cached latex again.
|
|
33
|
+
@property (nonatomic, assign) BOOL highlighted;
|
|
27
34
|
@property (nonatomic, copy, readonly) NSString *cachedLatex;
|
|
28
35
|
@property (nonatomic, strong, nullable) ENRMAccessibilityLabels *accessibilityLabels;
|
|
36
|
+
@property (nonatomic, copy, nullable) ENRMLatexErrorHandler onLatexError;
|
|
29
37
|
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
@property (nonatomic,
|
|
38
|
+
// Shared, runtime-mutable block props (context-menu gate + copy labels) read live
|
|
39
|
+
// at menu-open. Set to the root's shared instance at creation. See
|
|
40
|
+
// ENRMDynamicBlockProps.
|
|
41
|
+
@property (nonatomic, strong) ENRMDynamicBlockProps *dynamicProps;
|
|
34
42
|
|
|
35
43
|
/// Suppresses the long-press copy menu on this block. Mirrors the
|
|
36
44
|
/// `contextMenuHidden` prop; selection and link handling are unaffected.
|