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
|
@@ -26,7 +26,8 @@ static NSArray *ENRMSplitASTIntoSegments(MarkdownASTNode *root)
|
|
|
26
26
|
[currentTextNodes removeAllObjects];
|
|
27
27
|
}
|
|
28
28
|
NSString *latex = child.children.count > 0 ? child.children.firstObject.content : child.content;
|
|
29
|
-
|
|
29
|
+
BOOL highlighted = [child.attributes[@"highlight"] isEqualToString:@"true"];
|
|
30
|
+
[segments addObject:[ENRMMathSegment segmentWithLatex:latex ?: @"" highlighted:highlighted]];
|
|
30
31
|
#else
|
|
31
32
|
// TODO: Fix block math rendering on macOS. Adding ENRMMathContainerView as a
|
|
32
33
|
// segment causes all preceding text segments to become invisible.
|
|
@@ -39,7 +40,23 @@ static NSArray *ENRMSplitASTIntoSegments(MarkdownASTNode *root)
|
|
|
39
40
|
[currentTextNodes removeAllObjects];
|
|
40
41
|
}
|
|
41
42
|
[segments addObject:[ENRMCodeBlockSegment segmentWithCodeBlockNode:child]];
|
|
42
|
-
} else {
|
|
43
|
+
} else if (child.type == MarkdownNodeTypeBlockquote || child.type == MarkdownNodeTypeAdmonition) {
|
|
44
|
+
if (currentTextNodes.count > 0) {
|
|
45
|
+
[segments addObject:[ENRMTextSegment segmentWithNodes:[currentTextNodes copy]]];
|
|
46
|
+
[currentTextNodes removeAllObjects];
|
|
47
|
+
}
|
|
48
|
+
[segments addObject:[ENRMBlockquoteSegment segmentWithBlockquoteNode:child]];
|
|
49
|
+
}
|
|
50
|
+
#if ENRICHED_MARKDOWN_VIDEO
|
|
51
|
+
else if (child.type == MarkdownNodeTypeVideo) {
|
|
52
|
+
if (currentTextNodes.count > 0) {
|
|
53
|
+
[segments addObject:[ENRMTextSegment segmentWithNodes:[currentTextNodes copy]]];
|
|
54
|
+
[currentTextNodes removeAllObjects];
|
|
55
|
+
}
|
|
56
|
+
[segments addObject:[ENRMVideoSegment segmentWithVideoNode:child]];
|
|
57
|
+
}
|
|
58
|
+
#endif
|
|
59
|
+
else {
|
|
43
60
|
[currentTextNodes addObject:child];
|
|
44
61
|
}
|
|
45
62
|
}
|
|
@@ -54,21 +71,26 @@ static NSArray *ENRMSplitASTIntoSegments(MarkdownASTNode *root)
|
|
|
54
71
|
NSArray<ENRMRenderedSegment *> *ENRMRenderSegmentsFromAST(MarkdownASTNode *ast, StyleConfig *config,
|
|
55
72
|
BOOL allowTrailingMargin, BOOL allowFontScaling,
|
|
56
73
|
CGFloat maxFontSizeMultiplier,
|
|
57
|
-
NSLineBreakStrategy lineBreakStrategy)
|
|
74
|
+
NSLineBreakStrategy lineBreakStrategy, BOOL blockquoteContent)
|
|
58
75
|
{
|
|
59
76
|
NSArray *segments = ENRMSplitASTIntoSegments(ast);
|
|
60
77
|
NSMutableArray<ENRMRenderedSegment *> *renderedSegments = [NSMutableArray array];
|
|
61
78
|
|
|
62
|
-
static const uint64_t kTextKindSalt = 0x7465787400000000ULL;
|
|
63
|
-
static const uint64_t kTableKindSalt = 0x7461626C00000000ULL;
|
|
64
|
-
static const uint64_t kMathKindSalt = 0x6D61746800000000ULL;
|
|
65
|
-
static const uint64_t kCodeBlockKindSalt = 0x63626C6B00000000ULL;
|
|
79
|
+
static const uint64_t kTextKindSalt = 0x7465787400000000ULL; // "text"
|
|
80
|
+
static const uint64_t kTableKindSalt = 0x7461626C00000000ULL; // "tabl"
|
|
81
|
+
static const uint64_t kMathKindSalt = 0x6D61746800000000ULL; // "math"
|
|
82
|
+
static const uint64_t kCodeBlockKindSalt = 0x63626C6B00000000ULL; // "cblk"
|
|
83
|
+
static const uint64_t kBlockquoteKindSalt = 0x6271746500000000ULL; // "bqte"
|
|
84
|
+
static const uint64_t kVideoKindSalt = 0x7669646F00000000ULL; // "vido"
|
|
66
85
|
|
|
67
86
|
for (id segment in segments) {
|
|
68
87
|
if ([segment isKindOfClass:[ENRMTextSegment class]]) {
|
|
69
88
|
ENRMTextSegment *textSegment = (ENRMTextSegment *)segment;
|
|
70
|
-
ENRMRenderResult *rendered =
|
|
71
|
-
|
|
89
|
+
ENRMRenderResult *rendered = blockquoteContent
|
|
90
|
+
? ENRMRenderBlockquoteContentNodes(textSegment.nodes, config, allowFontScaling,
|
|
91
|
+
maxFontSizeMultiplier, lineBreakStrategy)
|
|
92
|
+
: ENRMRenderASTNodes(textSegment.nodes, config, allowTrailingMargin,
|
|
93
|
+
allowFontScaling, maxFontSizeMultiplier, lineBreakStrategy);
|
|
72
94
|
uint64_t signature = ENRMSignatureForNodes(textSegment.nodes) ^ kTextKindSalt;
|
|
73
95
|
[renderedSegments addObject:[ENRMRenderedSegment textSegmentWithResult:rendered signature:signature]];
|
|
74
96
|
} else if ([segment isKindOfClass:[ENRMTableSegment class]]) {
|
|
@@ -86,6 +108,9 @@ NSArray<ENRMRenderedSegment *> *ENRMRenderSegmentsFromAST(MarkdownASTNode *ast,
|
|
|
86
108
|
signature ^= (uint8_t)*utf8++;
|
|
87
109
|
signature *= 1099511628211ULL;
|
|
88
110
|
}
|
|
111
|
+
// A highlight toggle keeps the latex, so it must change the signature or the view is skipped.
|
|
112
|
+
signature ^= mathSegment.highlighted ? 1ULL : 0ULL;
|
|
113
|
+
signature *= 1099511628211ULL;
|
|
89
114
|
[renderedSegments addObject:[ENRMRenderedSegment mathSegmentWithSegment:mathSegment signature:signature]];
|
|
90
115
|
}
|
|
91
116
|
#endif
|
|
@@ -94,7 +119,19 @@ NSArray<ENRMRenderedSegment *> *ENRMRenderSegmentsFromAST(MarkdownASTNode *ast,
|
|
|
94
119
|
uint64_t signature = ENRMSignatureForNode(codeBlockSegment.codeBlockNode) ^ kCodeBlockKindSalt;
|
|
95
120
|
[renderedSegments addObject:[ENRMRenderedSegment codeBlockSegmentWithSegment:codeBlockSegment
|
|
96
121
|
signature:signature]];
|
|
122
|
+
} else if ([segment isKindOfClass:[ENRMBlockquoteSegment class]]) {
|
|
123
|
+
ENRMBlockquoteSegment *blockquoteSegment = (ENRMBlockquoteSegment *)segment;
|
|
124
|
+
uint64_t signature = ENRMSignatureForNode(blockquoteSegment.blockquoteNode) ^ kBlockquoteKindSalt;
|
|
125
|
+
[renderedSegments addObject:[ENRMRenderedSegment blockquoteSegmentWithSegment:blockquoteSegment
|
|
126
|
+
signature:signature]];
|
|
127
|
+
}
|
|
128
|
+
#if ENRICHED_MARKDOWN_VIDEO
|
|
129
|
+
else if ([segment isKindOfClass:[ENRMVideoSegment class]]) {
|
|
130
|
+
ENRMVideoSegment *videoSegment = (ENRMVideoSegment *)segment;
|
|
131
|
+
uint64_t signature = ENRMSignatureForNode(videoSegment.videoNode) ^ kVideoKindSalt;
|
|
132
|
+
[renderedSegments addObject:[ENRMRenderedSegment videoSegmentWithSegment:videoSegment signature:signature]];
|
|
97
133
|
}
|
|
134
|
+
#endif
|
|
98
135
|
}
|
|
99
136
|
|
|
100
137
|
return renderedSegments;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
#import "ENRMBlockMenu.h"
|
|
3
|
+
#import "ENRMDynamicBlockProps.h"
|
|
3
4
|
#import "ENRMUIKit.h"
|
|
4
5
|
#import "ParagraphStyleUtils.h"
|
|
5
6
|
#import "StyleConfig.h"
|
|
@@ -48,10 +49,10 @@ typedef void (^TableLinkPressBlock)(NSString *url);
|
|
|
48
49
|
|
|
49
50
|
@property (nonatomic, strong, nullable) ENRMAccessibilityLabels *accessibilityLabels;
|
|
50
51
|
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
@property (nonatomic,
|
|
52
|
+
// Shared, runtime-mutable block props (context-menu gate + copy labels) read live
|
|
53
|
+
// at menu-open. Set to the root's shared instance at creation. See
|
|
54
|
+
// ENRMDynamicBlockProps.
|
|
55
|
+
@property (nonatomic, strong) ENRMDynamicBlockProps *dynamicProps;
|
|
55
56
|
|
|
56
57
|
/// Suppresses the long-press copy menu on this block. Mirrors the
|
|
57
58
|
/// `contextMenuHidden` prop; selection and link handling are unaffected.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#import "AttributedRenderer.h"
|
|
3
3
|
#import "ENRMAccessibilityLabels.h"
|
|
4
4
|
#import "ENRMLinkChip.h"
|
|
5
|
+
#import "ENRMImageAttachment.h"
|
|
5
6
|
#import "HTMLGenerator.h"
|
|
6
7
|
#import "LinkTapUtils.h"
|
|
7
8
|
#import "MarkdownASTNode.h"
|
|
@@ -78,22 +79,18 @@ static NSMutableAttributedString *ENRMTableRenderCellNode(MarkdownASTNode *cellN
|
|
|
78
79
|
ENRMWritingDirectionMode writingDirectionMode,
|
|
79
80
|
NSWritingDirection resolvedLayoutDirection)
|
|
80
81
|
{
|
|
81
|
-
MarkdownASTNode *temporaryRoot = [[MarkdownASTNode alloc] initWithType:MarkdownNodeTypeDocument];
|
|
82
|
-
for (MarkdownASTNode *child in cellNode.children) {
|
|
83
|
-
[temporaryRoot addChild:child];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
82
|
AttributedRenderer *renderer = [[AttributedRenderer alloc] initWithConfig:cellConfig];
|
|
87
83
|
RenderContext *context = [RenderContext new];
|
|
88
84
|
context.allowFontScaling = allowFontScaling;
|
|
89
85
|
context.maxFontSizeMultiplier = maxFontSizeMultiplier;
|
|
90
86
|
|
|
91
|
-
NSMutableAttributedString *attributedText = [renderer
|
|
87
|
+
NSMutableAttributedString *attributedText = [renderer renderNodes:cellNode.children context:context block:nil];
|
|
92
88
|
|
|
93
89
|
[context applyLinkAttributesToString:attributedText];
|
|
94
90
|
// Cells draw with -drawWithRect:, which bypasses the layout manager that paints link chips.
|
|
95
91
|
ENRMApplyLinkChipBackgroundsAsTextBackground(attributedText);
|
|
96
92
|
|
|
93
|
+
ENRMPinLineMetricsToStyledFonts(attributedText, NSMakeRange(0, attributedText.length));
|
|
97
94
|
ENRMApplyWritingDirectionMode(attributedText, writingDirectionMode, resolvedLayoutDirection);
|
|
98
95
|
|
|
99
96
|
if (alignment != NSTextAlignmentLeft && attributedText.length > 0) {
|
|
@@ -113,6 +110,29 @@ static NSMutableAttributedString *ENRMTableRenderCellNode(MarkdownASTNode *cellN
|
|
|
113
110
|
return attributedText;
|
|
114
111
|
}
|
|
115
112
|
|
|
113
|
+
// The grid rasterizes each cell's attributed string via -drawWithRect: in a single
|
|
114
|
+
// drawRect: pass, so an image attachment loading asynchronously has no live text view
|
|
115
|
+
// to invalidate (its -refreshDisplay no-ops). Point every cell image at the grid's own
|
|
116
|
+
// redraw so the cell repaints once the image finishes loading.
|
|
117
|
+
static void ENRMTableWireImageRedraw(NSArray<NSArray<TableCellData *> *> *rows, void (^redraw)(void))
|
|
118
|
+
{
|
|
119
|
+
for (NSArray<TableCellData *> *row in rows) {
|
|
120
|
+
for (TableCellData *cell in row) {
|
|
121
|
+
NSAttributedString *text = cell.attributedText;
|
|
122
|
+
if (text.length == 0)
|
|
123
|
+
continue;
|
|
124
|
+
[text enumerateAttribute:NSAttachmentAttributeName
|
|
125
|
+
inRange:NSMakeRange(0, text.length)
|
|
126
|
+
options:0
|
|
127
|
+
usingBlock:^(id value, NSRange range, BOOL *stop) {
|
|
128
|
+
if ([value isKindOfClass:[ENRMImageAttachment class]]) {
|
|
129
|
+
((ENRMImageAttachment *)value).onImageLoaded = redraw;
|
|
130
|
+
}
|
|
131
|
+
}];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
116
136
|
static NSArray<NSArray<TableCellData *> *> *ENRMTableBuildRows(MarkdownASTNode *tableNode, StyleConfig *config,
|
|
117
137
|
BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
|
|
118
138
|
ENRMWritingDirectionMode writingDirectionMode,
|
|
@@ -231,6 +251,8 @@ static void ENRMTableComputeLayout(NSArray<NSArray<TableCellData *> *> *rows, NS
|
|
|
231
251
|
NSString *_cachedMarkdown;
|
|
232
252
|
|
|
233
253
|
NSArray *_cachedAccessibilityElements;
|
|
254
|
+
|
|
255
|
+
BOOL _imageRemeasurePending;
|
|
234
256
|
}
|
|
235
257
|
|
|
236
258
|
- (instancetype)initWithConfig:(StyleConfig *)config
|
|
@@ -241,6 +263,7 @@ static void ENRMTableComputeLayout(NSArray<NSArray<TableCellData *> *> *rows, NS
|
|
|
241
263
|
_allowFontScaling = YES;
|
|
242
264
|
_maxFontSizeMultiplier = 0;
|
|
243
265
|
_enableLinkPreview = YES;
|
|
266
|
+
_dynamicProps = [[ENRMDynamicBlockProps alloc] init];
|
|
244
267
|
_writingDirectionMode = ENRMWritingDirectionModeFirstStrong;
|
|
245
268
|
_resolvedLayoutDirection = NSWritingDirectionLeftToRight;
|
|
246
269
|
[self setupScrollView];
|
|
@@ -267,15 +290,17 @@ static void ENRMTableComputeLayout(NSArray<NSArray<TableCellData *> *> *rows, NS
|
|
|
267
290
|
// a single drawRect: pass (no subview / layer compositing issues).
|
|
268
291
|
ENRMTableGridView *gridView = [[ENRMTableGridView alloc] initWithFrame:CGRectZero];
|
|
269
292
|
__weak TableContainerView *weakSelf = self;
|
|
270
|
-
gridView.menuProvider = ^NSMenu *
|
|
293
|
+
gridView.menuProvider = ^NSMenu *
|
|
294
|
+
{
|
|
271
295
|
TableContainerView *strongSelf = weakSelf;
|
|
272
|
-
if (!strongSelf)
|
|
296
|
+
if (!strongSelf || !strongSelf.dynamicProps.enableBlockContextMenu)
|
|
273
297
|
return nil;
|
|
274
298
|
if (strongSelf.contextMenuHidden)
|
|
275
299
|
return nil;
|
|
276
300
|
NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
|
|
277
|
-
[menu addItem:ENRMCreateMenuItem(strongSelf.
|
|
278
|
-
[menu addItem:ENRMCreateMenuItem(strongSelf.
|
|
301
|
+
[menu addItem:ENRMCreateMenuItem(strongSelf.dynamicProps.menuCopyLabel, ^{ [strongSelf copyTableToPasteboard]; })];
|
|
302
|
+
[menu addItem:ENRMCreateMenuItem(strongSelf.dynamicProps.menuCopyAsMarkdownLabel,
|
|
303
|
+
^{ [strongSelf copyMarkdownToPasteboard]; })];
|
|
279
304
|
return menu;
|
|
280
305
|
};
|
|
281
306
|
_gridContainer = gridView;
|
|
@@ -442,6 +467,9 @@ static void ENRMTableComputeLayout(NSArray<NSArray<TableCellData *> *> *rows, NS
|
|
|
442
467
|
horizontalCellPadding:self.config.tableCellPaddingHorizontal
|
|
443
468
|
verticalCellPadding:self.config.tableCellPaddingVertical
|
|
444
469
|
cornerRadius:self.config.tableBorderRadius];
|
|
470
|
+
|
|
471
|
+
__weak TableContainerView *weakSelf = self;
|
|
472
|
+
ENRMTableWireImageRedraw(_rows, ^{ [weakSelf handleCellImageResolved]; });
|
|
445
473
|
}
|
|
446
474
|
|
|
447
475
|
#else
|
|
@@ -477,24 +505,80 @@ static void ENRMTableComputeLayout(NSArray<NSArray<TableCellData *> *> *rows, NS
|
|
|
477
505
|
horizontalCellPadding:self.config.tableCellPaddingHorizontal
|
|
478
506
|
verticalCellPadding:self.config.tableCellPaddingVertical
|
|
479
507
|
cornerRadius:self.config.tableBorderRadius];
|
|
508
|
+
|
|
509
|
+
__weak TableContainerView *weakSelf = self;
|
|
510
|
+
ENRMTableWireImageRedraw(_rows, ^{ [weakSelf handleCellImageResolved]; });
|
|
511
|
+
}
|
|
512
|
+
#endif
|
|
513
|
+
|
|
514
|
+
// A dynamic cell image (maxHeight / aspectRatio) resolves its box height only after
|
|
515
|
+
// loading. Recompute this table's layout locally; if a row height actually changed
|
|
516
|
+
// (the maxHeight fitted case), re-render and ask the host to re-measure its Fabric
|
|
517
|
+
// height, otherwise just repaint the freshly loaded pixels. The height guard makes this
|
|
518
|
+
// a no-op once heights are stable, so a deterministic image never churns, and the host's
|
|
519
|
+
// own needs-update guard stops the propagation from looping.
|
|
520
|
+
- (void)handleCellImageResolved
|
|
521
|
+
{
|
|
522
|
+
if (_imageRemeasurePending) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
_imageRemeasurePending = YES;
|
|
526
|
+
__weak TableContainerView *weakSelf = self;
|
|
527
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
528
|
+
TableContainerView *strongSelf = weakSelf;
|
|
529
|
+
if (!strongSelf) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
strongSelf->_imageRemeasurePending = NO;
|
|
533
|
+
[strongSelf remeasureForCellImage];
|
|
534
|
+
});
|
|
480
535
|
}
|
|
536
|
+
|
|
537
|
+
- (void)remeasureForCellImage
|
|
538
|
+
{
|
|
539
|
+
if (_rows.count == 0) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
NSArray<NSNumber *> *oldRowHeights = _rowHeights;
|
|
543
|
+
CGFloat oldTotalHeight = _totalTableHeight;
|
|
544
|
+
[self computeLayout];
|
|
545
|
+
|
|
546
|
+
BOOL changed = ![_rowHeights isEqualToArray:oldRowHeights] || fabs(_totalTableHeight - oldTotalHeight) > 0.5;
|
|
547
|
+
if (!changed) {
|
|
548
|
+
#if TARGET_OS_OSX
|
|
549
|
+
_gridContainer.needsDisplay = YES;
|
|
550
|
+
#else
|
|
551
|
+
[_gridContainer setNeedsDisplay];
|
|
481
552
|
#endif
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
[self renderGrid];
|
|
557
|
+
[self setNeedsLayout];
|
|
558
|
+
|
|
559
|
+
[[self.superview enrm_imageLayoutObserver] imageAttachmentDidResolveLayout];
|
|
560
|
+
}
|
|
482
561
|
|
|
483
562
|
#if !TARGET_OS_OSX
|
|
484
563
|
- (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction
|
|
485
564
|
configurationForMenuAtLocation:(CGPoint)location
|
|
486
565
|
{
|
|
487
566
|
// Returning nil is the UIKit-sanctioned way to suppress a context menu.
|
|
567
|
+
// `contextMenuHidden` (fork) wins over `enableBlockContextMenu` (upstream #708) and still
|
|
568
|
+
// reports the block through onMenuSuppressed (merge decision D1).
|
|
488
569
|
if (self.contextMenuHidden) {
|
|
489
570
|
if (self.onMenuSuppressed) {
|
|
490
571
|
self.onMenuSuppressed(_cachedMarkdown ?: @"", [self buildPlainTextFromRows] ?: @"");
|
|
491
572
|
}
|
|
492
573
|
return nil;
|
|
493
574
|
}
|
|
575
|
+
if (!self.dynamicProps.enableBlockContextMenu) {
|
|
576
|
+
return nil;
|
|
577
|
+
}
|
|
494
578
|
__weak __typeof(self) weakSelf = self;
|
|
495
579
|
return ENRMBlockContextMenuConfiguration(
|
|
496
|
-
self.menuOptions, self.
|
|
497
|
-
^{ [weakSelf copyMarkdownToPasteboard]; }, ^{ [weakSelf requestCopy]; });
|
|
580
|
+
self.menuOptions, self.dynamicProps.menuCopyLabel, self.dynamicProps.menuCopyAsMarkdownLabel,
|
|
581
|
+
^{ [weakSelf copyTableToPasteboard]; }, ^{ [weakSelf copyMarkdownToPasteboard]; }, ^{ [weakSelf requestCopy]; });
|
|
498
582
|
}
|
|
499
583
|
|
|
500
584
|
- (void)requestCopy
|
package/ios/styles/StyleConfig.h
CHANGED
|
@@ -9,6 +9,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
9
9
|
* Populated from the JS `linkVariants` map by StylePropsUtils and consumed by LinkRenderer.
|
|
10
10
|
*/
|
|
11
11
|
@interface LinkVariantConfig : NSObject
|
|
12
|
+
@property (nonatomic, copy) NSString *fontFamily;
|
|
12
13
|
@property (nonatomic, copy) NSString *pattern;
|
|
13
14
|
@property (nonatomic, strong) RCTUIColor *color;
|
|
14
15
|
@property (nonatomic, assign) BOOL underline;
|
|
@@ -238,6 +239,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
238
239
|
- (void)setImageMarginBottom:(CGFloat)newValue;
|
|
239
240
|
- (nullable NSDictionary<NSString *, NSString *> *)imageRequestHeaders;
|
|
240
241
|
- (void)setImageRequestHeaders:(nullable NSDictionary<NSString *, NSString *> *)newValue;
|
|
242
|
+
// Video properties
|
|
243
|
+
- (CGFloat)videoMarginTop;
|
|
244
|
+
- (void)setVideoMarginTop:(CGFloat)newValue;
|
|
245
|
+
- (CGFloat)videoMarginBottom;
|
|
246
|
+
- (void)setVideoMarginBottom:(CGFloat)newValue;
|
|
247
|
+
- (CGFloat)videoBorderRadius;
|
|
248
|
+
- (void)setVideoBorderRadius:(CGFloat)newValue;
|
|
249
|
+
- (CGFloat)videoAspectRatio;
|
|
250
|
+
- (void)setVideoAspectRatio:(CGFloat)newValue;
|
|
251
|
+
- (RCTUIColor *)videoBackgroundColor;
|
|
252
|
+
- (void)setVideoBackgroundColor:(RCTUIColor *)newValue;
|
|
241
253
|
// Inline image properties
|
|
242
254
|
- (CGFloat)inlineImageSize;
|
|
243
255
|
- (void)setInlineImageSize:(CGFloat)newValue;
|
|
@@ -269,6 +281,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
269
281
|
- (void)setBlockquoteBorderRadius:(CGFloat)newValue;
|
|
270
282
|
- (CGFloat)blockquotePadding;
|
|
271
283
|
- (void)setBlockquotePadding:(CGFloat)newValue;
|
|
284
|
+
// Per-admonition-type colors (keyed by "note"/"tip"/"important"/"warning"/"caution").
|
|
285
|
+
- (void)setAdmonitionColors:(NSDictionary<NSString *, RCTUIColor *> *)colors
|
|
286
|
+
backgroundColors:(NSDictionary<NSString *, RCTUIColor *> *)backgroundColors;
|
|
287
|
+
- (RCTUIColor *)admonitionColorForType:(NSString *)type;
|
|
288
|
+
- (RCTUIColor *)admonitionBackgroundColorForType:(NSString *)type;
|
|
272
289
|
// List style properties (combined for both ordered and unordered lists)
|
|
273
290
|
- (CGFloat)listStyleFontSize;
|
|
274
291
|
- (void)setListStyleFontSize:(CGFloat)newValue;
|
|
@@ -150,6 +150,12 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
|
|
|
150
150
|
CGFloat _imageMarginTop;
|
|
151
151
|
CGFloat _imageMarginBottom;
|
|
152
152
|
NSDictionary<NSString *, NSString *> *_imageRequestHeaders;
|
|
153
|
+
// Video properties
|
|
154
|
+
CGFloat _videoMarginTop;
|
|
155
|
+
CGFloat _videoMarginBottom;
|
|
156
|
+
CGFloat _videoBorderRadius;
|
|
157
|
+
CGFloat _videoAspectRatio;
|
|
158
|
+
RCTUIColor *_videoBackgroundColor;
|
|
153
159
|
// Inline image properties
|
|
154
160
|
CGFloat _inlineImageSize;
|
|
155
161
|
// Blockquote properties
|
|
@@ -166,6 +172,9 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
|
|
|
166
172
|
RCTUIColor *_blockquoteBackgroundColor;
|
|
167
173
|
CGFloat _blockquoteBorderRadius;
|
|
168
174
|
CGFloat _blockquotePadding;
|
|
175
|
+
// Per-admonition-type colors keyed by type ("note"/"tip"/…). Empty until set.
|
|
176
|
+
NSDictionary<NSString *, RCTUIColor *> *_admonitionColors;
|
|
177
|
+
NSDictionary<NSString *, RCTUIColor *> *_admonitionBackgroundColors;
|
|
169
178
|
ENRMFontSlot *_blockquoteFont;
|
|
170
179
|
// List style properties (combined for both ordered and unordered lists)
|
|
171
180
|
CGFloat _listStyleFontSize;
|
|
@@ -296,6 +305,8 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
|
|
|
296
305
|
_primaryFont, _paragraphFont, _h1Font, _h2Font, _h3Font, _h4Font, _h5Font, _h6Font, _listMarkerFont, _listStyleFont,
|
|
297
306
|
_codeBlockFont, _blockquoteFont, _tableFont, _tableHeaderFont
|
|
298
307
|
];
|
|
308
|
+
_admonitionColors = @{};
|
|
309
|
+
_admonitionBackgroundColors = @{};
|
|
299
310
|
return self;
|
|
300
311
|
}
|
|
301
312
|
|
|
@@ -442,6 +453,11 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
|
|
|
442
453
|
copy->_imageMarginTop = _imageMarginTop;
|
|
443
454
|
copy->_imageMarginBottom = _imageMarginBottom;
|
|
444
455
|
copy->_imageRequestHeaders = [_imageRequestHeaders copy];
|
|
456
|
+
copy->_videoMarginTop = _videoMarginTop;
|
|
457
|
+
copy->_videoMarginBottom = _videoMarginBottom;
|
|
458
|
+
copy->_videoBorderRadius = _videoBorderRadius;
|
|
459
|
+
copy->_videoAspectRatio = _videoAspectRatio;
|
|
460
|
+
copy->_videoBackgroundColor = [_videoBackgroundColor copy];
|
|
445
461
|
copy->_inlineImageSize = _inlineImageSize;
|
|
446
462
|
copy->_blockquoteFontSize = _blockquoteFontSize;
|
|
447
463
|
copy->_blockquoteFontFamily = [_blockquoteFontFamily copy];
|
|
@@ -456,6 +472,8 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
|
|
|
456
472
|
copy->_blockquoteBackgroundColor = [_blockquoteBackgroundColor copy];
|
|
457
473
|
copy->_blockquoteBorderRadius = _blockquoteBorderRadius;
|
|
458
474
|
copy->_blockquotePadding = _blockquotePadding;
|
|
475
|
+
copy->_admonitionColors = [_admonitionColors copy];
|
|
476
|
+
copy->_admonitionBackgroundColors = [_admonitionBackgroundColors copy];
|
|
459
477
|
copy->_listStyleFontSize = _listStyleFontSize;
|
|
460
478
|
copy->_listStyleFontFamily = [_listStyleFontFamily copy];
|
|
461
479
|
copy->_listStyleFontWeight = [_listStyleFontWeight copy];
|
|
@@ -1669,6 +1687,56 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
|
|
|
1669
1687
|
_imageRequestHeaders = [newValue copy];
|
|
1670
1688
|
}
|
|
1671
1689
|
|
|
1690
|
+
- (CGFloat)videoMarginTop
|
|
1691
|
+
{
|
|
1692
|
+
return _videoMarginTop;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
- (void)setVideoMarginTop:(CGFloat)newValue
|
|
1696
|
+
{
|
|
1697
|
+
_videoMarginTop = newValue;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
- (CGFloat)videoMarginBottom
|
|
1701
|
+
{
|
|
1702
|
+
return _videoMarginBottom;
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
- (void)setVideoMarginBottom:(CGFloat)newValue
|
|
1706
|
+
{
|
|
1707
|
+
_videoMarginBottom = newValue;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
- (CGFloat)videoBorderRadius
|
|
1711
|
+
{
|
|
1712
|
+
return _videoBorderRadius;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
- (void)setVideoBorderRadius:(CGFloat)newValue
|
|
1716
|
+
{
|
|
1717
|
+
_videoBorderRadius = newValue;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
- (CGFloat)videoAspectRatio
|
|
1721
|
+
{
|
|
1722
|
+
return _videoAspectRatio;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
- (void)setVideoAspectRatio:(CGFloat)newValue
|
|
1726
|
+
{
|
|
1727
|
+
_videoAspectRatio = newValue;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
- (RCTUIColor *)videoBackgroundColor
|
|
1731
|
+
{
|
|
1732
|
+
return _videoBackgroundColor;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
- (void)setVideoBackgroundColor:(RCTUIColor *)newValue
|
|
1736
|
+
{
|
|
1737
|
+
_videoBackgroundColor = newValue;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1672
1740
|
- (CGFloat)inlineImageSize
|
|
1673
1741
|
{
|
|
1674
1742
|
return _inlineImageSize;
|
|
@@ -1831,6 +1899,28 @@ static inline NSString *normalizedFontWeight(NSString *fontWeight)
|
|
|
1831
1899
|
_blockquotePadding = newValue;
|
|
1832
1900
|
}
|
|
1833
1901
|
|
|
1902
|
+
- (void)setAdmonitionColors:(NSDictionary<NSString *, RCTUIColor *> *)colors
|
|
1903
|
+
backgroundColors:(NSDictionary<NSString *, RCTUIColor *> *)backgroundColors
|
|
1904
|
+
{
|
|
1905
|
+
_admonitionColors = [colors copy];
|
|
1906
|
+
_admonitionBackgroundColors = [backgroundColors copy];
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
// The tint (border + title + icon) for an admonition type; falls back to the
|
|
1910
|
+
// base blockquote border color if the type was never configured.
|
|
1911
|
+
- (RCTUIColor *)admonitionColorForType:(NSString *)type
|
|
1912
|
+
{
|
|
1913
|
+
RCTUIColor *color = _admonitionColors[type];
|
|
1914
|
+
return color ?: _blockquoteBorderColor;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
// The callout fill for an admonition type; clear (no fill) when unset.
|
|
1918
|
+
- (RCTUIColor *)admonitionBackgroundColorForType:(NSString *)type
|
|
1919
|
+
{
|
|
1920
|
+
RCTUIColor *color = _admonitionBackgroundColors[type];
|
|
1921
|
+
return color ?: [RCTUIColor clearColor];
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1834
1924
|
// List style properties (combined for both ordered and unordered lists)
|
|
1835
1925
|
- (CGFloat)listStyleFontSize
|
|
1836
1926
|
{
|
|
@@ -75,5 +75,18 @@ void ENRMApplyCodeBlockTextAttributes(NSMutableAttributedString *string, NSRange
|
|
|
75
75
|
NSMutableParagraphStyle *paragraphStyle = [getOrCreateParagraphStyle(string, range.location) mutableCopy];
|
|
76
76
|
paragraphStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
|
|
77
77
|
paragraphStyle.alignment = NSTextAlignmentLeft;
|
|
78
|
+
// Re-clamp unconditionally (applyLineHeight carves math/block-image lines out of its clamp,
|
|
79
|
+
// fork D7 option b). Code blocks reserve their height analytically as
|
|
80
|
+
// lineCount * lineHeight (ENRMCodeBlockCodeHeight), so a line must not grow past the
|
|
81
|
+
// configured lineHeight or a tall run (emoji, wide glyph) would overflow and clip the block.
|
|
82
|
+
if (lineHeight > 0) {
|
|
83
|
+
paragraphStyle.maximumLineHeight = lineHeight;
|
|
84
|
+
}
|
|
78
85
|
[string addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range];
|
|
86
|
+
|
|
87
|
+
if (lineHeight > 0) {
|
|
88
|
+
applyBaselineOffset(string, range);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
ENRMPinLineMetricsToStyledFonts(string, range);
|
|
79
92
|
}
|
|
@@ -17,3 +17,9 @@
|
|
|
17
17
|
#if !defined(ENRICHED_MARKDOWN_CODE_HIGHLIGHT)
|
|
18
18
|
#define ENRICHED_MARKDOWN_CODE_HIGHLIGHT 0
|
|
19
19
|
#endif
|
|
20
|
+
|
|
21
|
+
// Video playback support. Uses AVKit (built into both iOS and macOS — no
|
|
22
|
+
// external framework), so the flag gates only the container view code itself.
|
|
23
|
+
#if !defined(ENRICHED_MARKDOWN_VIDEO)
|
|
24
|
+
#define ENRICHED_MARKDOWN_VIDEO 0
|
|
25
|
+
#endif
|
|
@@ -23,6 +23,14 @@ ENRMRenderResult *ENRMRenderASTNodes(NSArray<MarkdownASTNode *> *nodes, StyleCon
|
|
|
23
23
|
BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
|
|
24
24
|
NSLineBreakStrategy lineBreakStrategy);
|
|
25
25
|
|
|
26
|
+
// Renders a blockquote's own text content: like ENRMRenderASTNodes but with a blockquote baseline
|
|
27
|
+
// (tight paragraphs, quote font/color) and the quote's line height applied over the result. Draws
|
|
28
|
+
// no box - the ENRMBlockquoteContainerView draws the border/background/padding. Mirrors Android's
|
|
29
|
+
// BlockquoteTextRenderer.
|
|
30
|
+
ENRMRenderResult *ENRMRenderBlockquoteContentNodes(NSArray<MarkdownASTNode *> *nodes, StyleConfig *config,
|
|
31
|
+
BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
|
|
32
|
+
NSLineBreakStrategy lineBreakStrategy);
|
|
33
|
+
|
|
26
34
|
#ifdef __cplusplus
|
|
27
35
|
}
|
|
28
36
|
#endif
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#import "ENRMTextRenderer.h"
|
|
2
2
|
#import "AccessibilityInfo.h"
|
|
3
3
|
#import "AttributedRenderer.h"
|
|
4
|
-
#import "
|
|
4
|
+
#import "ENRMBlockquoteTextRenderer.h"
|
|
5
5
|
#import "ParagraphStyleUtils.h"
|
|
6
6
|
#import "RenderContext.h"
|
|
7
7
|
#import "StyleConfig.h"
|
|
@@ -9,15 +9,11 @@
|
|
|
9
9
|
@implementation ENRMRenderResult
|
|
10
10
|
@end
|
|
11
11
|
|
|
12
|
-
ENRMRenderResult *
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
static ENRMRenderResult *ENRMRenderASTNodesCore(NSArray<MarkdownASTNode *> *nodes, StyleConfig *config,
|
|
13
|
+
BOOL allowTrailingMargin, BOOL allowFontScaling,
|
|
14
|
+
CGFloat maxFontSizeMultiplier, NSLineBreakStrategy lineBreakStrategy,
|
|
15
|
+
ENRMBlockquoteTextRenderer *block)
|
|
15
16
|
{
|
|
16
|
-
MarkdownASTNode *root = [[MarkdownASTNode alloc] initWithType:MarkdownNodeTypeDocument];
|
|
17
|
-
for (MarkdownASTNode *node in nodes) {
|
|
18
|
-
[root addChild:node];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
17
|
AttributedRenderer *renderer = [[AttributedRenderer alloc] initWithConfig:config];
|
|
22
18
|
[renderer setAllowTrailingMargin:allowTrailingMargin];
|
|
23
19
|
|
|
@@ -25,9 +21,12 @@ ENRMRenderResult *ENRMRenderASTNodes(NSArray<MarkdownASTNode *> *nodes, StyleCon
|
|
|
25
21
|
context.allowFontScaling = allowFontScaling;
|
|
26
22
|
context.maxFontSizeMultiplier = maxFontSizeMultiplier;
|
|
27
23
|
|
|
28
|
-
NSMutableAttributedString *attributedText = [renderer
|
|
24
|
+
NSMutableAttributedString *attributedText = [renderer renderNodes:nodes context:context block:block];
|
|
25
|
+
|
|
29
26
|
[context applyLinkAttributesToString:attributedText];
|
|
27
|
+
[context applyImageAttributesToString:attributedText];
|
|
30
28
|
ENRMApplyLineBreakStrategyToParagraphStyles(attributedText, lineBreakStrategy);
|
|
29
|
+
ENRMPinLineMetricsToStyledFonts(attributedText, NSMakeRange(0, attributedText.length));
|
|
31
30
|
|
|
32
31
|
ENRMRenderResult *result = [[ENRMRenderResult alloc] init];
|
|
33
32
|
result.attributedText = attributedText;
|
|
@@ -36,3 +35,20 @@ ENRMRenderResult *ENRMRenderASTNodes(NSArray<MarkdownASTNode *> *nodes, StyleCon
|
|
|
36
35
|
result.lastElementMarginBottom = [renderer getLastElementMarginBottom];
|
|
37
36
|
return result;
|
|
38
37
|
}
|
|
38
|
+
|
|
39
|
+
ENRMRenderResult *ENRMRenderASTNodes(NSArray<MarkdownASTNode *> *nodes, StyleConfig *config, BOOL allowTrailingMargin,
|
|
40
|
+
BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
|
|
41
|
+
NSLineBreakStrategy lineBreakStrategy)
|
|
42
|
+
{
|
|
43
|
+
return ENRMRenderASTNodesCore(nodes, config, allowTrailingMargin, allowFontScaling, maxFontSizeMultiplier,
|
|
44
|
+
lineBreakStrategy, /*block*/ nil);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ENRMRenderResult *ENRMRenderBlockquoteContentNodes(NSArray<MarkdownASTNode *> *nodes, StyleConfig *config,
|
|
48
|
+
BOOL allowFontScaling, CGFloat maxFontSizeMultiplier,
|
|
49
|
+
NSLineBreakStrategy lineBreakStrategy)
|
|
50
|
+
{
|
|
51
|
+
ENRMBlockquoteTextRenderer *block = [[ENRMBlockquoteTextRenderer alloc] initWithConfig:config];
|
|
52
|
+
return ENRMRenderASTNodesCore(nodes, config, /*allowTrailingMargin*/ NO, allowFontScaling, maxFontSizeMultiplier,
|
|
53
|
+
lineBreakStrategy, block);
|
|
54
|
+
}
|
package/ios/utils/ENRMUIKit.h
CHANGED
|
@@ -273,6 +273,7 @@ static inline void ENRMConfigureMarkdownTextView(ENRMPlatformTextView *textView)
|
|
|
273
273
|
textView.drawsBackground = NO;
|
|
274
274
|
#endif
|
|
275
275
|
textView.textContainer.lineFragmentPadding = 0;
|
|
276
|
+
textView.layoutManager.usesFontLeading = NO;
|
|
276
277
|
textView.linkTextAttributes = @{};
|
|
277
278
|
textView.selectable = YES;
|
|
278
279
|
#if !TARGET_OS_OSX
|
package/ios/utils/FontUtils.h
CHANGED
|
@@ -19,7 +19,8 @@ extern UIFont *cachedFontFromBlockStyle(BlockStyle *blockStyle, RenderContext *c
|
|
|
19
19
|
extern CGFloat RCTFontSizeMultiplierWithMax(CGFloat maxFontSizeMultiplier);
|
|
20
20
|
|
|
21
21
|
/** Converts a CSS-style font weight string to a UIFontWeight constant.
|
|
22
|
-
*
|
|
22
|
+
* Mirrors React Native's RCTFont table: "100"/"ultralight" through
|
|
23
|
+
* "900"/"black", plus the "normal"/"regular"/"bold"/etc. aliases.
|
|
23
24
|
* Returns UIFontWeightRegular for unrecognised or nil input. */
|
|
24
25
|
extern UIFontWeight ENRMFontWeightFromString(NSString *_Nullable weightString);
|
|
25
26
|
|
package/ios/utils/FontUtils.m
CHANGED
|
@@ -31,17 +31,33 @@ UIFontWeight ENRMFontWeightFromString(NSString *weightString)
|
|
|
31
31
|
if (weightString.length == 0) {
|
|
32
32
|
return UIFontWeightRegular;
|
|
33
33
|
}
|
|
34
|
-
if ([weightString isEqualToString:@"
|
|
35
|
-
return
|
|
34
|
+
if ([weightString isEqualToString:@"ultralight"] || [weightString isEqualToString:@"100"]) {
|
|
35
|
+
return UIFontWeightUltraLight;
|
|
36
36
|
}
|
|
37
|
-
if ([weightString isEqualToString:@"
|
|
38
|
-
return
|
|
37
|
+
if ([weightString isEqualToString:@"thin"] || [weightString isEqualToString:@"200"]) {
|
|
38
|
+
return UIFontWeightThin;
|
|
39
|
+
}
|
|
40
|
+
if ([weightString isEqualToString:@"light"] || [weightString isEqualToString:@"300"]) {
|
|
41
|
+
return UIFontWeightLight;
|
|
42
|
+
}
|
|
43
|
+
if ([weightString isEqualToString:@"normal"] || [weightString isEqualToString:@"regular"] ||
|
|
44
|
+
[weightString isEqualToString:@"400"]) {
|
|
45
|
+
return UIFontWeightRegular;
|
|
39
46
|
}
|
|
40
47
|
if ([weightString isEqualToString:@"medium"] || [weightString isEqualToString:@"500"]) {
|
|
41
48
|
return UIFontWeightMedium;
|
|
42
49
|
}
|
|
43
|
-
if ([weightString isEqualToString:@"
|
|
44
|
-
return
|
|
50
|
+
if ([weightString isEqualToString:@"semibold"] || [weightString isEqualToString:@"600"]) {
|
|
51
|
+
return UIFontWeightSemibold;
|
|
52
|
+
}
|
|
53
|
+
if ([weightString isEqualToString:@"bold"] || [weightString isEqualToString:@"700"]) {
|
|
54
|
+
return UIFontWeightBold;
|
|
55
|
+
}
|
|
56
|
+
if ([weightString isEqualToString:@"heavy"] || [weightString isEqualToString:@"800"]) {
|
|
57
|
+
return UIFontWeightHeavy;
|
|
58
|
+
}
|
|
59
|
+
if ([weightString isEqualToString:@"black"] || [weightString isEqualToString:@"900"]) {
|
|
60
|
+
return UIFontWeightBlack;
|
|
45
61
|
}
|
|
46
62
|
return UIFontWeightRegular;
|
|
47
63
|
}
|