@mathers101/react-native-render-rich-text 0.0.0-stage → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +140 -3
- package/ReactNativeRenderRichText.podspec +23 -0
- package/android/build.gradle +86 -0
- package/android/consumer-rules.pro +3 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/jni-adapter.cpp +191 -0
- package/android/src/main/java/com/renderrichtext/EnrichedTiptapText.kt +673 -0
- package/android/src/main/java/com/renderrichtext/EnrichedTiptapTextLayoutManager.kt +24 -0
- package/android/src/main/java/com/renderrichtext/EnrichedTiptapTextManager.kt +405 -0
- package/android/src/main/java/com/renderrichtext/EnrichedTiptapTextPackage.kt +13 -0
- package/android/src/main/java/com/renderrichtext/MeasurementStore.kt +644 -0
- package/android/src/main/java/com/renderrichtext/accessibility/AccessibilityLabels.kt +17 -0
- package/android/src/main/java/com/renderrichtext/accessibility/AccessibleTiptapTextView.kt +112 -0
- package/android/src/main/java/com/renderrichtext/accessibility/TiptapAccessibilityHelper.kt +576 -0
- package/android/src/main/java/com/renderrichtext/events/CodeBlockPressEvent.kt +24 -0
- package/android/src/main/java/com/renderrichtext/events/ContextMenuItemPressEvent.kt +28 -0
- package/android/src/main/java/com/renderrichtext/events/CopyPressEvent.kt +24 -0
- package/android/src/main/java/com/renderrichtext/events/FactoidPressEvent.kt +23 -0
- package/android/src/main/java/com/renderrichtext/events/ImagePressEvent.kt +25 -0
- package/android/src/main/java/com/renderrichtext/events/LatexErrorEvent.kt +29 -0
- package/android/src/main/java/com/renderrichtext/events/LinkLongPressEvent.kt +23 -0
- package/android/src/main/java/com/renderrichtext/events/LinkPressEvent.kt +23 -0
- package/android/src/main/java/com/renderrichtext/events/MentionLongPressEvent.kt +25 -0
- package/android/src/main/java/com/renderrichtext/events/MentionPressEvent.kt +25 -0
- package/android/src/main/java/com/renderrichtext/events/TaskListItemPressEvent.kt +26 -0
- package/android/src/main/java/com/renderrichtext/math/LatexErrorReporter.kt +9 -0
- package/android/src/main/java/com/renderrichtext/parser/Parser.kt +59 -0
- package/android/src/main/java/com/renderrichtext/parser/TextLinkMatching.kt +35 -0
- package/android/src/main/java/com/renderrichtext/parser/TiptapASTNode.kt +69 -0
- package/android/src/main/java/com/renderrichtext/renderer/BaselineShiftRenderer.kt +45 -0
- package/android/src/main/java/com/renderrichtext/renderer/BlankLineRenderer.kt +39 -0
- package/android/src/main/java/com/renderrichtext/renderer/BlockStyleContext.kt +181 -0
- package/android/src/main/java/com/renderrichtext/renderer/BlockquoteRenderer.kt +243 -0
- package/android/src/main/java/com/renderrichtext/renderer/BlockquoteTextRenderer.kt +56 -0
- package/android/src/main/java/com/renderrichtext/renderer/CodeBlockRenderer.kt +135 -0
- package/android/src/main/java/com/renderrichtext/renderer/CodeRenderer.kt +37 -0
- package/android/src/main/java/com/renderrichtext/renderer/EmphasisRenderer.kt +28 -0
- package/android/src/main/java/com/renderrichtext/renderer/FactoidRenderer.kt +97 -0
- package/android/src/main/java/com/renderrichtext/renderer/HeadingRenderer.kt +81 -0
- package/android/src/main/java/com/renderrichtext/renderer/HighlightRenderer.kt +26 -0
- package/android/src/main/java/com/renderrichtext/renderer/LineBreakRenderer.kt +17 -0
- package/android/src/main/java/com/renderrichtext/renderer/LinkRenderer.kt +90 -0
- package/android/src/main/java/com/renderrichtext/renderer/ListContextManager.kt +109 -0
- package/android/src/main/java/com/renderrichtext/renderer/ListItemRenderer.kt +211 -0
- package/android/src/main/java/com/renderrichtext/renderer/ListRenderer.kt +133 -0
- package/android/src/main/java/com/renderrichtext/renderer/MentionRenderer.kt +85 -0
- package/android/src/main/java/com/renderrichtext/renderer/NodeRenderer.kt +207 -0
- package/android/src/main/java/com/renderrichtext/renderer/ParagraphRenderer.kt +91 -0
- package/android/src/main/java/com/renderrichtext/renderer/Renderer.kt +148 -0
- package/android/src/main/java/com/renderrichtext/renderer/SoftBreakRenderer.kt +17 -0
- package/android/src/main/java/com/renderrichtext/renderer/SpanStyleCache.kt +143 -0
- package/android/src/main/java/com/renderrichtext/renderer/StrikethroughRenderer.kt +28 -0
- package/android/src/main/java/com/renderrichtext/renderer/StrongRenderer.kt +28 -0
- package/android/src/main/java/com/renderrichtext/renderer/TextRenderer.kt +31 -0
- package/android/src/main/java/com/renderrichtext/renderer/ThematicBreakRenderer.kt +46 -0
- package/android/src/main/java/com/renderrichtext/renderer/UnderlineRenderer.kt +28 -0
- package/android/src/main/java/com/renderrichtext/spans/BaseListSpan.kt +164 -0
- package/android/src/main/java/com/renderrichtext/spans/BaselineShiftSpan.kt +27 -0
- package/android/src/main/java/com/renderrichtext/spans/BlockquoteSpan.kt +302 -0
- package/android/src/main/java/com/renderrichtext/spans/CodeBackgroundSpan.kt +205 -0
- package/android/src/main/java/com/renderrichtext/spans/CodeBlockSpan.kt +216 -0
- package/android/src/main/java/com/renderrichtext/spans/CodeSpan.kt +32 -0
- package/android/src/main/java/com/renderrichtext/spans/EmphasisSpan.kt +42 -0
- package/android/src/main/java/com/renderrichtext/spans/FactoidBackgroundSpan.kt +265 -0
- package/android/src/main/java/com/renderrichtext/spans/FactoidPaddingSpan.kt +258 -0
- package/android/src/main/java/com/renderrichtext/spans/FactoidSpan.kt +32 -0
- package/android/src/main/java/com/renderrichtext/spans/FadeInSpan.kt +29 -0
- package/android/src/main/java/com/renderrichtext/spans/HeadingSpan.kt +38 -0
- package/android/src/main/java/com/renderrichtext/spans/HighlightSpan.kt +80 -0
- package/android/src/main/java/com/renderrichtext/spans/ImageSpan.kt +481 -0
- package/android/src/main/java/com/renderrichtext/spans/InlineBackgroundGeometry.kt +42 -0
- package/android/src/main/java/com/renderrichtext/spans/LineHeightSpan.kt +39 -0
- package/android/src/main/java/com/renderrichtext/spans/LinkPillIconCache.kt +154 -0
- package/android/src/main/java/com/renderrichtext/spans/LinkPillSpan.kt +381 -0
- package/android/src/main/java/com/renderrichtext/spans/LinkSpan.kt +68 -0
- package/android/src/main/java/com/renderrichtext/spans/ListItemSpacingSpan.kt +33 -0
- package/android/src/main/java/com/renderrichtext/spans/ListMarkerAnchorSpan.kt +38 -0
- package/android/src/main/java/com/renderrichtext/spans/MarginBottomSpan.kt +76 -0
- package/android/src/main/java/com/renderrichtext/spans/MentionChipSpan.kt +132 -0
- package/android/src/main/java/com/renderrichtext/spans/MentionSpan.kt +46 -0
- package/android/src/main/java/com/renderrichtext/spans/OrderedListSpan.kt +127 -0
- package/android/src/main/java/com/renderrichtext/spans/SpoilerSpan.kt +33 -0
- package/android/src/main/java/com/renderrichtext/spans/StrikethroughSpan.kt +12 -0
- package/android/src/main/java/com/renderrichtext/spans/StrongSpan.kt +39 -0
- package/android/src/main/java/com/renderrichtext/spans/TaskListSpan.kt +143 -0
- package/android/src/main/java/com/renderrichtext/spans/TextSpan.kt +26 -0
- package/android/src/main/java/com/renderrichtext/spans/ThematicBreakSpan.kt +69 -0
- package/android/src/main/java/com/renderrichtext/spans/UnorderedListSpan.kt +96 -0
- package/android/src/main/java/com/renderrichtext/spoiler/SpoilerStubs.kt +46 -0
- package/android/src/main/java/com/renderrichtext/styles/BaseBlockStyle.kt +11 -0
- package/android/src/main/java/com/renderrichtext/styles/BlockquoteStyle.kt +83 -0
- package/android/src/main/java/com/renderrichtext/styles/CodeBlockStyle.kt +80 -0
- package/android/src/main/java/com/renderrichtext/styles/CodeStyle.kt +26 -0
- package/android/src/main/java/com/renderrichtext/styles/EmphasisStyle.kt +21 -0
- package/android/src/main/java/com/renderrichtext/styles/FactoidStyle.kt +21 -0
- package/android/src/main/java/com/renderrichtext/styles/HeadingStyle.kt +33 -0
- package/android/src/main/java/com/renderrichtext/styles/HighlightStyle.kt +19 -0
- package/android/src/main/java/com/renderrichtext/styles/ImageStyle.kt +29 -0
- package/android/src/main/java/com/renderrichtext/styles/InlineImageStyle.kt +17 -0
- package/android/src/main/java/com/renderrichtext/styles/InlineMathStyle.kt +17 -0
- package/android/src/main/java/com/renderrichtext/styles/LinkPillContent.kt +36 -0
- package/android/src/main/java/com/renderrichtext/styles/LinkPillStyle.kt +44 -0
- package/android/src/main/java/com/renderrichtext/styles/LinkStyle.kt +23 -0
- package/android/src/main/java/com/renderrichtext/styles/LinkVariantEntry.kt +34 -0
- package/android/src/main/java/com/renderrichtext/styles/ListStyle.kt +65 -0
- package/android/src/main/java/com/renderrichtext/styles/MathStyle.kt +29 -0
- package/android/src/main/java/com/renderrichtext/styles/MentionStyle.kt +19 -0
- package/android/src/main/java/com/renderrichtext/styles/ParagraphStyle.kt +33 -0
- package/android/src/main/java/com/renderrichtext/styles/SpoilerStyle.kt +27 -0
- package/android/src/main/java/com/renderrichtext/styles/StrikethroughStyle.kt +17 -0
- package/android/src/main/java/com/renderrichtext/styles/StrongStyle.kt +21 -0
- package/android/src/main/java/com/renderrichtext/styles/StyleConfig.kt +411 -0
- package/android/src/main/java/com/renderrichtext/styles/StyleParser.kt +92 -0
- package/android/src/main/java/com/renderrichtext/styles/SubscriptStyle.kt +16 -0
- package/android/src/main/java/com/renderrichtext/styles/SuperscriptStyle.kt +16 -0
- package/android/src/main/java/com/renderrichtext/styles/TableStyle.kt +75 -0
- package/android/src/main/java/com/renderrichtext/styles/TaskListStyle.kt +29 -0
- package/android/src/main/java/com/renderrichtext/styles/TextAlignment.kt +32 -0
- package/android/src/main/java/com/renderrichtext/styles/ThematicBreakStyle.kt +23 -0
- package/android/src/main/java/com/renderrichtext/styles/UnderlineStyle.kt +17 -0
- package/android/src/main/java/com/renderrichtext/styles/VideoStyle.kt +31 -0
- package/android/src/main/java/com/renderrichtext/utils/common/BorderStyleUtils.kt +86 -0
- package/android/src/main/java/com/renderrichtext/utils/common/BreakStrategyUtils.kt +32 -0
- package/android/src/main/java/com/renderrichtext/utils/common/CodeBlockHighlighter.kt +36 -0
- package/android/src/main/java/com/renderrichtext/utils/common/CodeBlockNode.kt +42 -0
- package/android/src/main/java/com/renderrichtext/utils/common/EllipsizeUtils.kt +27 -0
- package/android/src/main/java/com/renderrichtext/utils/common/EnrichedTiptapAncestorUtils.kt +10 -0
- package/android/src/main/java/com/renderrichtext/utils/common/FeatureFlags.kt +9 -0
- package/android/src/main/java/com/renderrichtext/utils/common/LinkRecognitionProps.kt +31 -0
- package/android/src/main/java/com/renderrichtext/utils/common/LinkRegexConfig.kt +56 -0
- package/android/src/main/java/com/renderrichtext/utils/common/MotionPreferences.kt +18 -0
- package/android/src/main/java/com/renderrichtext/utils/common/ReadableMapExtensions.kt +28 -0
- package/android/src/main/java/com/renderrichtext/utils/common/TiptapViewManagerUtils.kt +242 -0
- package/android/src/main/java/com/renderrichtext/utils/common/layout/RTLUtils.kt +6 -0
- package/android/src/main/java/com/renderrichtext/utils/common/serialization/TiptapASTSerializer.kt +368 -0
- package/android/src/main/java/com/renderrichtext/utils/text/ImageCache.kt +88 -0
- package/android/src/main/java/com/renderrichtext/utils/text/ImageDownloader.kt +203 -0
- package/android/src/main/java/com/renderrichtext/utils/text/LocalImageLoader.kt +167 -0
- package/android/src/main/java/com/renderrichtext/utils/text/TailFadeInAnimator.kt +84 -0
- package/android/src/main/java/com/renderrichtext/utils/text/conversion/HTMLGenerator.kt +1105 -0
- package/android/src/main/java/com/renderrichtext/utils/text/conversion/TiptapExtractor.kt +423 -0
- package/android/src/main/java/com/renderrichtext/utils/text/extensions/ParagraphUtils.kt +9 -0
- package/android/src/main/java/com/renderrichtext/utils/text/extensions/SpannableExtensions.kt +9 -0
- package/android/src/main/java/com/renderrichtext/utils/text/extensions/TextPaintExtensions.kt +76 -0
- package/android/src/main/java/com/renderrichtext/utils/text/interaction/CheckboxTouchHelper.kt +61 -0
- package/android/src/main/java/com/renderrichtext/utils/text/interaction/TaskListTapUtils.kt +286 -0
- package/android/src/main/java/com/renderrichtext/utils/text/span/ApplyLineHeight.kt +39 -0
- package/android/src/main/java/com/renderrichtext/utils/text/span/BlockSpacing.kt +142 -0
- package/android/src/main/java/com/renderrichtext/utils/text/span/SpanFlags.kt +43 -0
- package/android/src/main/java/com/renderrichtext/utils/text/span/WidthAwareSpans.kt +30 -0
- package/android/src/main/java/com/renderrichtext/utils/text/view/CodeBlockPressHost.kt +15 -0
- package/android/src/main/java/com/renderrichtext/utils/text/view/ImagePressHost.kt +19 -0
- package/android/src/main/java/com/renderrichtext/utils/text/view/LinkEvents.kt +88 -0
- package/android/src/main/java/com/renderrichtext/utils/text/view/LinkLongPressMovementMethod.kt +449 -0
- package/android/src/main/java/com/renderrichtext/utils/text/view/SelectionActionMode.kt +235 -0
- package/android/src/main/java/com/renderrichtext/utils/text/view/TextSelectionColors.kt +48 -0
- package/android/src/main/java/com/renderrichtext/utils/text/view/TextViewSetup.kt +119 -0
- package/android/src/main/java/com/renderrichtext/views/ContextMenuPopup.kt +217 -0
- package/android/src/main/java/com/renderrichtext/views/CopyGlyph.kt +101 -0
- package/android/src/main/java/com/renderrichtext/views/WrapGlyph.kt +40 -0
- package/android/src/main/jni/CMakeLists.txt +52 -0
- package/android/src/main/jni/react/renderer/components/RichTextSpec/ComponentDescriptors.h +30 -0
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextComponentDescriptor.h +29 -0
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextMeasurementManager.cpp +45 -0
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextMeasurementManager.h +21 -0
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextShadowNode.cpp +38 -0
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextShadowNode.h +53 -0
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextState.cpp +9 -0
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextState.h +24 -0
- package/android/src/main/jni/react/renderer/components/RichTextSpec/conversions.h +40 -0
- package/cpp/parser/TiptapASTNode.hpp +68 -0
- package/cpp/parser/TiptapParser.cpp +233 -0
- package/cpp/parser/TiptapParser.hpp +13 -0
- package/cpp/vendor/nlohmann/json.hpp +24765 -0
- package/ios/EnrichedTiptapText.h +27 -0
- package/ios/EnrichedTiptapText.mm +1222 -0
- package/ios/attachments/ENRMImageAttachment.h +51 -0
- package/ios/attachments/ENRMImageAttachment.m +398 -0
- package/ios/attachments/ENRMLinkPillAttachment.h +47 -0
- package/ios/attachments/ENRMLinkPillAttachment.m +324 -0
- package/ios/attachments/ENRMLinkPillIconCache.h +28 -0
- package/ios/attachments/ENRMLinkPillIconCache.m +181 -0
- package/ios/attachments/ENRMLinkPillText.h +27 -0
- package/ios/attachments/ENRMLinkPillText.m +118 -0
- package/ios/attachments/ENRMMathInlineAttachment.h +7 -0
- package/ios/attachments/ENRMMathInlineAttachment.m +4 -0
- package/ios/attachments/ThematicBreakAttachment.h +15 -0
- package/ios/attachments/ThematicBreakAttachment.m +33 -0
- package/ios/internals/ENRMViewFreeMeasurement.h +208 -0
- package/ios/internals/EnrichedTiptapTextComponentDescriptor.h +19 -0
- package/ios/internals/EnrichedTiptapTextShadowNode.h +43 -0
- package/ios/internals/EnrichedTiptapTextShadowNode.mm +69 -0
- package/ios/internals/EnrichedTiptapTextState.h +24 -0
- package/ios/internals/MeasurementCache.h +308 -0
- package/ios/internals/ShadowMeasurementUtils.h +145 -0
- package/ios/parser/ENRMTextLinkAttributes.h +7 -0
- package/ios/parser/ENRMTiptapParser.h +33 -0
- package/ios/parser/ENRMTiptapParser.mm +73 -0
- package/ios/parser/TiptapASTNode.h +57 -0
- package/ios/parser/TiptapASTNode.m +52 -0
- package/ios/parser/TiptapParserBridge.mm +179 -0
- package/ios/renderer/AttributedRenderer.h +23 -0
- package/ios/renderer/AttributedRenderer.m +229 -0
- package/ios/renderer/BaseRenderer.h +33 -0
- package/ios/renderer/BaseRenderer.m +46 -0
- package/ios/renderer/BaselineShiftTextAttributes.h +10 -0
- package/ios/renderer/BaselineShiftTextAttributes.m +26 -0
- package/ios/renderer/BlankLineRenderer.h +4 -0
- package/ios/renderer/BlankLineRenderer.m +51 -0
- package/ios/renderer/BlockquoteRenderer.h +6 -0
- package/ios/renderer/BlockquoteRenderer.m +258 -0
- package/ios/renderer/CodeBlockRenderer.h +9 -0
- package/ios/renderer/CodeBlockRenderer.m +99 -0
- package/ios/renderer/CodeRenderer.h +9 -0
- package/ios/renderer/CodeRenderer.m +69 -0
- package/ios/renderer/ENRMBlockquoteTextRenderer.h +25 -0
- package/ios/renderer/ENRMBlockquoteTextRenderer.m +48 -0
- package/ios/renderer/EmphasisRenderer.h +5 -0
- package/ios/renderer/EmphasisRenderer.m +100 -0
- package/ios/renderer/FactoidRenderer.h +9 -0
- package/ios/renderer/FactoidRenderer.m +130 -0
- package/ios/renderer/HeadingRenderer.h +6 -0
- package/ios/renderer/HeadingRenderer.m +103 -0
- package/ios/renderer/HighlightRenderer.h +7 -0
- package/ios/renderer/HighlightRenderer.m +33 -0
- package/ios/renderer/LinkRenderer.h +6 -0
- package/ios/renderer/LinkRenderer.m +158 -0
- package/ios/renderer/ListItemRenderer.h +24 -0
- package/ios/renderer/ListItemRenderer.m +283 -0
- package/ios/renderer/ListRenderer.h +13 -0
- package/ios/renderer/ListRenderer.m +126 -0
- package/ios/renderer/MentionRenderer.h +9 -0
- package/ios/renderer/MentionRenderer.m +96 -0
- package/ios/renderer/NodeRenderer.h +8 -0
- package/ios/renderer/ParagraphRenderer.h +6 -0
- package/ios/renderer/ParagraphRenderer.m +85 -0
- package/ios/renderer/RenderContext.h +145 -0
- package/ios/renderer/RenderContext.m +403 -0
- package/ios/renderer/RendererFactory.h +12 -0
- package/ios/renderer/RendererFactory.m +158 -0
- package/ios/renderer/StrikethroughRenderer.h +5 -0
- package/ios/renderer/StrikethroughRenderer.m +30 -0
- package/ios/renderer/StrongRenderer.h +5 -0
- package/ios/renderer/StrongRenderer.m +88 -0
- package/ios/renderer/TextRenderer.h +6 -0
- package/ios/renderer/TextRenderer.m +18 -0
- package/ios/renderer/ThematicBreakRenderer.h +4 -0
- package/ios/renderer/ThematicBreakRenderer.m +42 -0
- package/ios/renderer/UnderlineRenderer.h +4 -0
- package/ios/renderer/UnderlineRenderer.m +41 -0
- package/ios/styles/ENRMFontSlot.h +12 -0
- package/ios/styles/ENRMFontSlot.m +24 -0
- package/ios/styles/StyleConfig.h +488 -0
- package/ios/styles/StyleConfig.mm +2820 -0
- package/ios/utils/AccessibilityInfo.h +35 -0
- package/ios/utils/AccessibilityInfo.m +24 -0
- package/ios/utils/BlockquoteBorder.h +26 -0
- package/ios/utils/BlockquoteBorder.m +294 -0
- package/ios/utils/CodeBackground.h +19 -0
- package/ios/utils/CodeBackground.m +197 -0
- package/ios/utils/CodeBlockBackground.h +17 -0
- package/ios/utils/CodeBlockBackground.m +103 -0
- package/ios/utils/ContextMenuUtils.h +76 -0
- package/ios/utils/ContextMenuUtils.mm +75 -0
- package/ios/utils/ENRMAccessibilityLabels.h +40 -0
- package/ios/utils/ENRMAccessibilityLabels.m +5 -0
- package/ios/utils/ENRMAsyncRenderCoordinator.h +24 -0
- package/ios/utils/ENRMAsyncRenderCoordinator.m +37 -0
- package/ios/utils/ENRMAtomicSize.h +65 -0
- package/ios/utils/ENRMCodeBlockContent.h +37 -0
- package/ios/utils/ENRMCodeBlockContent.mm +89 -0
- package/ios/utils/ENRMFeatureFlags.h +25 -0
- package/ios/utils/ENRMImageDownloader.h +30 -0
- package/ios/utils/ENRMImageDownloader.m +168 -0
- package/ios/utils/ENRMLatexErrorCoordinator.h +27 -0
- package/ios/utils/ENRMLatexErrorCoordinator.mm +75 -0
- package/ios/utils/ENRMLatexErrorReporting.h +13 -0
- package/ios/utils/ENRMLinkContextMenus.h +93 -0
- package/ios/utils/ENRMLinkContextMenus.m +178 -0
- package/ios/utils/ENRMLinkRegexConfig.h +30 -0
- package/ios/utils/ENRMLinkRegexConfig.mm +104 -0
- package/ios/utils/ENRMLinkRegexProps.h +23 -0
- package/ios/utils/ENRMLocalImageLoader.h +35 -0
- package/ios/utils/ENRMLocalImageLoader.m +111 -0
- package/ios/utils/ENRMMenuAction.h +27 -0
- package/ios/utils/ENRMMenuAction.m +33 -0
- package/ios/utils/ENRMSpoilerOverlayManager.h +15 -0
- package/ios/utils/ENRMSpoilerOverlayManager.m +19 -0
- package/ios/utils/ENRMSpoilerTapUtils.h +6 -0
- package/ios/utils/ENRMSpoilerTapUtils.m +11 -0
- package/ios/utils/ENRMTailFadeInAnimator.h +16 -0
- package/ios/utils/ENRMTailFadeInAnimator.m +161 -0
- package/ios/utils/ENRMTextHitTest.h +23 -0
- package/ios/utils/ENRMTextHitTest.m +20 -0
- package/ios/utils/ENRMTextInteractionUtils.h +20 -0
- package/ios/utils/ENRMTextInteractionUtils.m +15 -0
- package/ios/utils/ENRMTextRenderer.h +38 -0
- package/ios/utils/ENRMTextRenderer.m +54 -0
- package/ios/utils/ENRMTextViewSetup.h +132 -0
- package/ios/utils/ENRMUIKit.h +429 -0
- package/ios/utils/EditMenuUtils.h +105 -0
- package/ios/utils/EditMenuUtils.m +143 -0
- package/ios/utils/FactoidBackground.h +20 -0
- package/ios/utils/FactoidBackground.m +161 -0
- package/ios/utils/FontScaleObserver.h +10 -0
- package/ios/utils/FontScaleObserver.m +55 -0
- package/ios/utils/FontUtils.h +31 -0
- package/ios/utils/FontUtils.m +63 -0
- package/ios/utils/HTMLGenerator.h +25 -0
- package/ios/utils/HTMLGenerator.m +1041 -0
- package/ios/utils/HeightUpdateUtils.h +25 -0
- package/ios/utils/ImageRequestHeaderUtils.h +35 -0
- package/ios/utils/LastElementUtils.h +97 -0
- package/ios/utils/LinkContextMenuUtils.h +55 -0
- package/ios/utils/LinkPillContentUtils.h +46 -0
- package/ios/utils/LinkTapUtils.h +56 -0
- package/ios/utils/LinkTapUtils.m +139 -0
- package/ios/utils/ListMarkerDrawer.h +15 -0
- package/ios/utils/ListMarkerDrawer.m +239 -0
- package/ios/utils/MentionBackground.h +26 -0
- package/ios/utils/MentionBackground.m +86 -0
- package/ios/utils/ParagraphStyleUtils.h +87 -0
- package/ios/utils/ParagraphStyleUtils.m +484 -0
- package/ios/utils/PasteboardUtils.h +48 -0
- package/ios/utils/PasteboardUtils.m +166 -0
- package/ios/utils/RTFExportUtils.h +24 -0
- package/ios/utils/RTFExportUtils.m +299 -0
- package/ios/utils/RuntimeKeys.h +44 -0
- package/ios/utils/RuntimeKeys.m +13 -0
- package/ios/utils/SelectionColorUtils.h +14 -0
- package/ios/utils/StylePropsUtils.h +1340 -0
- package/ios/utils/TaskListTapUtils.h +6 -0
- package/ios/utils/TaskListTapUtils.m +14 -0
- package/ios/utils/TextViewLayoutManager.h +14 -0
- package/ios/utils/TextViewLayoutManager.mm +198 -0
- package/ios/utils/TiptapAccessibilityElementBuilder.h +43 -0
- package/ios/utils/TiptapAccessibilityElementBuilder.m +432 -0
- package/ios/utils/TiptapExtractor.h +17 -0
- package/ios/utils/TiptapExtractor.m +367 -0
- package/ios/views/ENRMTiptapTextView.h +25 -0
- package/ios/views/ENRMTiptapTextView.m +247 -0
- package/package.json +70 -6
- package/react-native.config.js +10 -0
- package/src/EnrichedTiptapTextNativeComponent.ts +739 -0
- package/src/RichText.tsx +164 -0
- package/src/admonitionDefaults.ts +58 -0
- package/src/darkModeTextStyle.ts +99 -0
- package/src/headingDefaults.ts +21 -0
- package/src/index.tsx +4 -0
- package/src/linkVariantUtils.ts +120 -0
- package/src/normalizeTiptapStyle.ts +397 -0
- package/src/rn-globals.d.ts +1 -0
- package/src/styleUtils.ts +107 -0
- package/src/types/TiptapStyle.ts +532 -0
- package/src/types/TiptapStyleInternal.ts +299 -0
- package/src/types/linkPill.ts +9 -0
- package/src/utils/isDev.ts +4 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
package com.renderrichtext.spans
|
|
2
|
+
|
|
3
|
+
import android.graphics.Canvas
|
|
4
|
+
import android.graphics.Paint
|
|
5
|
+
import android.text.style.ReplacementSpan
|
|
6
|
+
|
|
7
|
+
class ThematicBreakSpan(
|
|
8
|
+
private val lineColor: Int,
|
|
9
|
+
private val lineHeight: Float,
|
|
10
|
+
private val marginTop: Float,
|
|
11
|
+
private val marginBottom: Float,
|
|
12
|
+
) : ReplacementSpan() {
|
|
13
|
+
override fun getSize(
|
|
14
|
+
paint: Paint,
|
|
15
|
+
text: CharSequence?,
|
|
16
|
+
start: Int,
|
|
17
|
+
end: Int,
|
|
18
|
+
fm: Paint.FontMetricsInt?,
|
|
19
|
+
): Int {
|
|
20
|
+
val totalHeight = (marginTop + lineHeight + marginBottom).toInt()
|
|
21
|
+
|
|
22
|
+
fm?.apply {
|
|
23
|
+
ascent = -totalHeight
|
|
24
|
+
top = -totalHeight
|
|
25
|
+
descent = 0
|
|
26
|
+
bottom = 0
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return 0
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override fun draw(
|
|
33
|
+
canvas: Canvas,
|
|
34
|
+
text: CharSequence?,
|
|
35
|
+
start: Int,
|
|
36
|
+
end: Int,
|
|
37
|
+
x: Float,
|
|
38
|
+
top: Int,
|
|
39
|
+
y: Int,
|
|
40
|
+
bottom: Int,
|
|
41
|
+
paint: Paint,
|
|
42
|
+
) {
|
|
43
|
+
paint.withStyle(lineColor, lineHeight) {
|
|
44
|
+
val lineY = top + marginTop + (lineHeight / 2f)
|
|
45
|
+
|
|
46
|
+
canvas.drawLine(0f, lineY, canvas.width.toFloat(), lineY, paint)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private inline fun Paint.withStyle(
|
|
51
|
+
color: Int,
|
|
52
|
+
width: Float,
|
|
53
|
+
action: () -> Unit,
|
|
54
|
+
) {
|
|
55
|
+
val oldColor = this.color
|
|
56
|
+
val oldWidth = this.strokeWidth
|
|
57
|
+
val oldStyle = this.style
|
|
58
|
+
|
|
59
|
+
this.color = color
|
|
60
|
+
this.strokeWidth = width
|
|
61
|
+
this.style = Paint.Style.STROKE
|
|
62
|
+
|
|
63
|
+
action()
|
|
64
|
+
|
|
65
|
+
this.color = oldColor
|
|
66
|
+
this.strokeWidth = oldWidth
|
|
67
|
+
this.style = oldStyle
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
package com.renderrichtext.spans
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.graphics.Canvas
|
|
5
|
+
import android.graphics.Paint
|
|
6
|
+
import android.text.Layout
|
|
7
|
+
import com.renderrichtext.renderer.BlockStyle
|
|
8
|
+
import com.renderrichtext.renderer.SpanStyleCache
|
|
9
|
+
import com.renderrichtext.styles.ListStyle
|
|
10
|
+
|
|
11
|
+
class UnorderedListSpan(
|
|
12
|
+
private val listStyle: ListStyle,
|
|
13
|
+
depth: Int,
|
|
14
|
+
context: Context,
|
|
15
|
+
styleCache: SpanStyleCache,
|
|
16
|
+
drawsMarker: Boolean = true,
|
|
17
|
+
ancestorMarkerOffset: Float = 0f,
|
|
18
|
+
parentMarkerWidth: Float? = null,
|
|
19
|
+
) : BaseListSpan(
|
|
20
|
+
depth = depth,
|
|
21
|
+
context = context,
|
|
22
|
+
styleCache = styleCache,
|
|
23
|
+
blockStyle =
|
|
24
|
+
BlockStyle(
|
|
25
|
+
fontSize = listStyle.fontSize,
|
|
26
|
+
fontFamily = listStyle.fontFamily,
|
|
27
|
+
fontWeight = listStyle.fontWeight,
|
|
28
|
+
color = listStyle.color,
|
|
29
|
+
),
|
|
30
|
+
marginLeft = listStyle.marginLeft,
|
|
31
|
+
gapWidth = listStyle.gapWidth,
|
|
32
|
+
drawsMarker = drawsMarker,
|
|
33
|
+
ancestorMarkerOffset = ancestorMarkerOffset,
|
|
34
|
+
parentMarkerWidth = parentMarkerWidth,
|
|
35
|
+
) {
|
|
36
|
+
companion object {
|
|
37
|
+
private val sharedBulletPaint =
|
|
38
|
+
Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
|
39
|
+
style = Paint.Style.FILL
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private val radius: Float = listStyle.bulletSize / 2f
|
|
44
|
+
private val ringStrokeWidth: Float = radius * 0.3f
|
|
45
|
+
// Same column an ordered list reserves for `99.`, so both lists indent equally.
|
|
46
|
+
private val markerColumnWidth: Float = OrderedListSpan.defaultMarkerColumnWidth(listStyle, context)
|
|
47
|
+
|
|
48
|
+
private fun configureBulletPaint(): Paint =
|
|
49
|
+
sharedBulletPaint.apply {
|
|
50
|
+
color = listStyle.bulletColor
|
|
51
|
+
style = Paint.Style.FILL
|
|
52
|
+
strokeWidth = 0f
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
override fun getMarkerWidth(): Float = markerColumnWidth
|
|
56
|
+
|
|
57
|
+
override fun drawMarker(
|
|
58
|
+
canvas: Canvas,
|
|
59
|
+
paint: Paint,
|
|
60
|
+
x: Int,
|
|
61
|
+
dir: Int,
|
|
62
|
+
top: Int,
|
|
63
|
+
baseline: Int,
|
|
64
|
+
bottom: Int,
|
|
65
|
+
layout: Layout?,
|
|
66
|
+
start: Int,
|
|
67
|
+
) {
|
|
68
|
+
val bulletPaint = configureBulletPaint()
|
|
69
|
+
// Right-align the bullet in the same column as a number, so its right edge
|
|
70
|
+
// meets the gap instead of sitting halfway into it.
|
|
71
|
+
val bulletX = x + (depth * marginLeft + ancestorMarkerOffset + markerColumnWidth - radius) * dir
|
|
72
|
+
val bulletY = baseline + (markerFontMetrics.ascent + markerFontMetrics.descent) / 2f
|
|
73
|
+
|
|
74
|
+
when (depth) {
|
|
75
|
+
0 -> {
|
|
76
|
+
canvas.drawCircle(bulletX, bulletY, radius, bulletPaint)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
1 -> {
|
|
80
|
+
bulletPaint.style = Paint.Style.STROKE
|
|
81
|
+
bulletPaint.strokeWidth = ringStrokeWidth
|
|
82
|
+
canvas.drawCircle(bulletX, bulletY, radius - ringStrokeWidth / 2f, bulletPaint)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
else -> {
|
|
86
|
+
canvas.drawRect(
|
|
87
|
+
bulletX - radius,
|
|
88
|
+
bulletY - radius,
|
|
89
|
+
bulletX + radius,
|
|
90
|
+
bulletY + radius,
|
|
91
|
+
bulletPaint,
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
package com.renderrichtext.spoiler
|
|
2
|
+
|
|
3
|
+
import android.graphics.Canvas
|
|
4
|
+
import android.text.Spanned
|
|
5
|
+
import android.view.View
|
|
6
|
+
import com.renderrichtext.spans.SpoilerSpan
|
|
7
|
+
|
|
8
|
+
enum class SpoilerOverlay {
|
|
9
|
+
NONE,
|
|
10
|
+
PARTICLES,
|
|
11
|
+
;
|
|
12
|
+
|
|
13
|
+
companion object {
|
|
14
|
+
fun fromString(value: String?): SpoilerOverlay = NONE
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class SpoilerOverlayDrawer {
|
|
19
|
+
fun draw(canvas: Canvas) {}
|
|
20
|
+
|
|
21
|
+
fun stop() {}
|
|
22
|
+
|
|
23
|
+
fun revealSpan(
|
|
24
|
+
span: SpoilerSpan,
|
|
25
|
+
onDone: () -> Unit,
|
|
26
|
+
) {
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
companion object {
|
|
30
|
+
fun setupIfNeeded(
|
|
31
|
+
view: View,
|
|
32
|
+
text: CharSequence?,
|
|
33
|
+
current: SpoilerOverlayDrawer?,
|
|
34
|
+
overlay: SpoilerOverlay,
|
|
35
|
+
): SpoilerOverlayDrawer? = null
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface SpoilerCapable {
|
|
40
|
+
val spoilerOverlayDrawer: SpoilerOverlayDrawer?
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fun Spanned.isConcealedBySpoiler(
|
|
44
|
+
start: Int,
|
|
45
|
+
end: Int,
|
|
46
|
+
): Boolean = false
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
/** Per-admonition-type colors. [color] tints border/title/icon; [backgroundColor] null = transparent. */
|
|
6
|
+
data class AdmonitionColors(
|
|
7
|
+
val color: Int,
|
|
8
|
+
val backgroundColor: Int?,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
data class BlockquoteStyle(
|
|
12
|
+
override val fontSize: Float,
|
|
13
|
+
override val fontFamily: String,
|
|
14
|
+
override val fontWeight: String,
|
|
15
|
+
override val color: Int,
|
|
16
|
+
override val marginTop: Float,
|
|
17
|
+
override val marginBottom: Float,
|
|
18
|
+
override val lineHeight: Float,
|
|
19
|
+
val borderColor: Int,
|
|
20
|
+
val borderWidth: Float,
|
|
21
|
+
val gapWidth: Float,
|
|
22
|
+
val backgroundColor: Int?,
|
|
23
|
+
val borderRadius: Float,
|
|
24
|
+
val padding: Float,
|
|
25
|
+
val admonitions: Map<String, AdmonitionColors>,
|
|
26
|
+
) : BaseBlockStyle {
|
|
27
|
+
companion object {
|
|
28
|
+
private fun parseAdmonitions(
|
|
29
|
+
map: ReadableMap,
|
|
30
|
+
parser: StyleParser,
|
|
31
|
+
): Map<String, AdmonitionColors> {
|
|
32
|
+
val admonitionsMap = map.getMap("admonitions") ?: return emptyMap()
|
|
33
|
+
val result = mutableMapOf<String, AdmonitionColors>()
|
|
34
|
+
for (type in listOf("note", "tip", "important", "warning", "caution")) {
|
|
35
|
+
val typeMap = admonitionsMap.getMap(type) ?: continue
|
|
36
|
+
result[type] =
|
|
37
|
+
AdmonitionColors(
|
|
38
|
+
parser.parseColor(typeMap, "color"),
|
|
39
|
+
parser.parseOptionalColor(typeMap, "backgroundColor"),
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
return result
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fun fromReadableMap(
|
|
46
|
+
map: ReadableMap,
|
|
47
|
+
parser: StyleParser,
|
|
48
|
+
): BlockquoteStyle {
|
|
49
|
+
val fontSize = parser.toPixelFromSP(map.getDouble("fontSize").toFloat())
|
|
50
|
+
val fontFamily = parser.parseString(map, "fontFamily")
|
|
51
|
+
val fontWeight = parser.parseString(map, "fontWeight", "normal")
|
|
52
|
+
val color = parser.parseColor(map, "color")
|
|
53
|
+
val marginTop = parser.toPixelFromDIP(map.getDouble("marginTop").toFloat())
|
|
54
|
+
val marginBottom = parser.toPixelFromDIP(map.getDouble("marginBottom").toFloat())
|
|
55
|
+
val lineHeightRaw = map.getDouble("lineHeight").toFloat()
|
|
56
|
+
val lineHeight = parser.toPixelFromSP(lineHeightRaw)
|
|
57
|
+
val borderColor = parser.parseColor(map, "borderColor")
|
|
58
|
+
val borderWidth = parser.toPixelFromDIP(map.getDouble("borderWidth").toFloat())
|
|
59
|
+
val gapWidth = parser.toPixelFromDIP(map.getDouble("gapWidth").toFloat())
|
|
60
|
+
val backgroundColor = parser.parseOptionalColor(map, "backgroundColor")
|
|
61
|
+
val borderRadius = parser.toPixelFromDIP(map.getDouble("borderRadius").toFloat())
|
|
62
|
+
val padding = parser.toPixelFromDIP(map.getDouble("padding").toFloat())
|
|
63
|
+
val admonitions = parseAdmonitions(map, parser)
|
|
64
|
+
|
|
65
|
+
return BlockquoteStyle(
|
|
66
|
+
fontSize,
|
|
67
|
+
fontFamily,
|
|
68
|
+
fontWeight,
|
|
69
|
+
color,
|
|
70
|
+
marginTop,
|
|
71
|
+
marginBottom,
|
|
72
|
+
lineHeight,
|
|
73
|
+
borderColor,
|
|
74
|
+
borderWidth,
|
|
75
|
+
gapWidth,
|
|
76
|
+
backgroundColor,
|
|
77
|
+
borderRadius,
|
|
78
|
+
padding,
|
|
79
|
+
admonitions,
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class CodeBlockStyle(
|
|
6
|
+
override val fontSize: Float,
|
|
7
|
+
override val fontFamily: String,
|
|
8
|
+
override val fontWeight: String,
|
|
9
|
+
override val color: Int,
|
|
10
|
+
override val marginTop: Float,
|
|
11
|
+
override val marginBottom: Float,
|
|
12
|
+
override val lineHeight: Float,
|
|
13
|
+
val backgroundColor: Int,
|
|
14
|
+
val borderColor: Int,
|
|
15
|
+
val borderRadius: Float,
|
|
16
|
+
val borderWidth: Float,
|
|
17
|
+
val padding: Float,
|
|
18
|
+
val syntaxColors: List<Int>,
|
|
19
|
+
) : BaseBlockStyle {
|
|
20
|
+
companion object {
|
|
21
|
+
private val SYNTAX_COLOR_KEYS =
|
|
22
|
+
listOf(
|
|
23
|
+
"keyword",
|
|
24
|
+
"operatorColor",
|
|
25
|
+
"punctuation",
|
|
26
|
+
"string",
|
|
27
|
+
"number",
|
|
28
|
+
"constant",
|
|
29
|
+
"comment",
|
|
30
|
+
"function",
|
|
31
|
+
"type",
|
|
32
|
+
"variable",
|
|
33
|
+
"property",
|
|
34
|
+
"tag",
|
|
35
|
+
"attribute",
|
|
36
|
+
"embedded",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
fun fromReadableMap(
|
|
40
|
+
map: ReadableMap,
|
|
41
|
+
parser: StyleParser,
|
|
42
|
+
): CodeBlockStyle {
|
|
43
|
+
val fontSize = parser.toPixelFromSP(map.getDouble("fontSize").toFloat())
|
|
44
|
+
val fontFamily = parser.parseString(map, "fontFamily")
|
|
45
|
+
val fontWeight = parser.parseString(map, "fontWeight", "normal")
|
|
46
|
+
val color = parser.parseColor(map, "color")
|
|
47
|
+
val marginTop = parser.toPixelFromDIP(map.getDouble("marginTop").toFloat())
|
|
48
|
+
val marginBottom = parser.toPixelFromDIP(map.getDouble("marginBottom").toFloat())
|
|
49
|
+
val lineHeightRaw = map.getDouble("lineHeight").toFloat()
|
|
50
|
+
val lineHeight = parser.toPixelFromSP(lineHeightRaw)
|
|
51
|
+
val backgroundColor = parser.parseColor(map, "backgroundColor")
|
|
52
|
+
val borderColor = parser.parseColor(map, "borderColor")
|
|
53
|
+
val borderRadius = parser.toPixelFromDIP(map.getDouble("borderRadius").toFloat())
|
|
54
|
+
val borderWidth = parser.toPixelFromDIP(map.getDouble("borderWidth").toFloat())
|
|
55
|
+
val padding = parser.toPixelFromDIP(map.getDouble("padding").toFloat())
|
|
56
|
+
|
|
57
|
+
val syntaxMap = map.getMap("syntaxColors")
|
|
58
|
+
val syntaxColors =
|
|
59
|
+
SYNTAX_COLOR_KEYS.map { key ->
|
|
60
|
+
syntaxMap?.let { parser.parseOptionalColor(it, key) } ?: color
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return CodeBlockStyle(
|
|
64
|
+
fontSize,
|
|
65
|
+
fontFamily,
|
|
66
|
+
fontWeight,
|
|
67
|
+
color,
|
|
68
|
+
marginTop,
|
|
69
|
+
marginBottom,
|
|
70
|
+
lineHeight,
|
|
71
|
+
backgroundColor,
|
|
72
|
+
borderColor,
|
|
73
|
+
borderRadius,
|
|
74
|
+
borderWidth,
|
|
75
|
+
padding,
|
|
76
|
+
syntaxColors,
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class CodeStyle(
|
|
6
|
+
val fontFamily: String,
|
|
7
|
+
val fontSize: Float,
|
|
8
|
+
val color: Int,
|
|
9
|
+
val backgroundColor: Int,
|
|
10
|
+
val borderColor: Int,
|
|
11
|
+
) {
|
|
12
|
+
companion object {
|
|
13
|
+
fun fromReadableMap(
|
|
14
|
+
map: ReadableMap,
|
|
15
|
+
parser: StyleParser,
|
|
16
|
+
): CodeStyle {
|
|
17
|
+
val fontFamily = parser.parseString(map, "fontFamily")
|
|
18
|
+
val fontSizeRaw = parser.parseOptionalDouble(map, "fontSize").toFloat()
|
|
19
|
+
val fontSize = if (fontSizeRaw > 0) parser.toPixelFromSP(fontSizeRaw) else 0f
|
|
20
|
+
val color = parser.parseColor(map, "color")
|
|
21
|
+
val backgroundColor = parser.parseColor(map, "backgroundColor")
|
|
22
|
+
val borderColor = parser.parseColor(map, "borderColor")
|
|
23
|
+
return CodeStyle(fontFamily, fontSize, color, backgroundColor, borderColor)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class EmphasisStyle(
|
|
6
|
+
val fontFamily: String,
|
|
7
|
+
val fontStyle: String,
|
|
8
|
+
val color: Int?,
|
|
9
|
+
) {
|
|
10
|
+
companion object {
|
|
11
|
+
fun fromReadableMap(
|
|
12
|
+
map: ReadableMap,
|
|
13
|
+
parser: StyleParser,
|
|
14
|
+
): EmphasisStyle {
|
|
15
|
+
val fontFamily = parser.parseString(map, "fontFamily")
|
|
16
|
+
val fontStyle = parser.parseString(map, "fontStyle")
|
|
17
|
+
val color = parser.parseOptionalColor(map, "color")
|
|
18
|
+
return EmphasisStyle(fontFamily, fontStyle, color)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class FactoidStyle(
|
|
6
|
+
val color: Int,
|
|
7
|
+
val backgroundColor: Int,
|
|
8
|
+
val borderColor: Int,
|
|
9
|
+
) {
|
|
10
|
+
companion object {
|
|
11
|
+
fun fromReadableMap(
|
|
12
|
+
map: ReadableMap,
|
|
13
|
+
parser: StyleParser,
|
|
14
|
+
): FactoidStyle {
|
|
15
|
+
val color = parser.parseColor(map, "color")
|
|
16
|
+
val backgroundColor = parser.parseColor(map, "backgroundColor")
|
|
17
|
+
val borderColor = parser.parseColor(map, "borderColor")
|
|
18
|
+
return FactoidStyle(color, backgroundColor, borderColor)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class HeadingStyle(
|
|
6
|
+
override val fontSize: Float,
|
|
7
|
+
override val fontFamily: String,
|
|
8
|
+
override val fontWeight: String,
|
|
9
|
+
override val color: Int,
|
|
10
|
+
override val marginTop: Float,
|
|
11
|
+
override val marginBottom: Float,
|
|
12
|
+
override val lineHeight: Float,
|
|
13
|
+
val textAlign: TextAlignment,
|
|
14
|
+
) : BaseBlockStyle {
|
|
15
|
+
companion object {
|
|
16
|
+
fun fromReadableMap(
|
|
17
|
+
map: ReadableMap,
|
|
18
|
+
parser: StyleParser,
|
|
19
|
+
): HeadingStyle {
|
|
20
|
+
val fontSize = parser.toPixelFromSP(map.getDouble("fontSize").toFloat())
|
|
21
|
+
val fontFamily = parser.parseString(map, "fontFamily")
|
|
22
|
+
val fontWeight = parser.parseString(map, "fontWeight", "normal")
|
|
23
|
+
val color = parser.parseColor(map, "color")
|
|
24
|
+
val marginTop = parser.toPixelFromDIP(map.getDouble("marginTop").toFloat())
|
|
25
|
+
val marginBottom = parser.toPixelFromDIP(map.getDouble("marginBottom").toFloat())
|
|
26
|
+
val lineHeightRaw = map.getDouble("lineHeight").toFloat()
|
|
27
|
+
val lineHeight = parser.toPixelFromSP(lineHeightRaw)
|
|
28
|
+
val textAlign = parser.parseTextAlign(map, "textAlign")
|
|
29
|
+
|
|
30
|
+
return HeadingStyle(fontSize, fontFamily, fontWeight, color, marginTop, marginBottom, lineHeight, textAlign)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class HighlightStyle(
|
|
6
|
+
val color: Int,
|
|
7
|
+
val backgroundColor: Int,
|
|
8
|
+
) {
|
|
9
|
+
companion object {
|
|
10
|
+
fun fromReadableMap(
|
|
11
|
+
map: ReadableMap,
|
|
12
|
+
parser: StyleParser,
|
|
13
|
+
): HighlightStyle {
|
|
14
|
+
val color = parser.parseColor(map, "color")
|
|
15
|
+
val backgroundColor = parser.parseColor(map, "backgroundColor")
|
|
16
|
+
return HighlightStyle(color, backgroundColor)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class ImageStyle(
|
|
6
|
+
val height: Float,
|
|
7
|
+
val maxHeight: Float,
|
|
8
|
+
val aspectRatio: Float,
|
|
9
|
+
val resizeMode: String,
|
|
10
|
+
val borderRadius: Float,
|
|
11
|
+
val marginTop: Float,
|
|
12
|
+
val marginBottom: Float,
|
|
13
|
+
) {
|
|
14
|
+
companion object {
|
|
15
|
+
fun fromReadableMap(
|
|
16
|
+
map: ReadableMap,
|
|
17
|
+
parser: StyleParser,
|
|
18
|
+
): ImageStyle {
|
|
19
|
+
val height = parser.toPixelFromDIP(map.getDouble("height").toFloat())
|
|
20
|
+
val maxHeight = parser.toPixelFromDIP(map.getDouble("maxHeight").toFloat())
|
|
21
|
+
val aspectRatio = map.getDouble("aspectRatio").toFloat()
|
|
22
|
+
val resizeMode = map.getString("resizeMode") ?: ""
|
|
23
|
+
val borderRadius = parser.toPixelFromDIP(map.getDouble("borderRadius").toFloat())
|
|
24
|
+
val marginTop = parser.toPixelFromDIP(map.getDouble("marginTop").toFloat())
|
|
25
|
+
val marginBottom = parser.toPixelFromDIP(map.getDouble("marginBottom").toFloat())
|
|
26
|
+
return ImageStyle(height, maxHeight, aspectRatio, resizeMode, borderRadius, marginTop, marginBottom)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class InlineImageStyle(
|
|
6
|
+
val size: Float,
|
|
7
|
+
) {
|
|
8
|
+
companion object {
|
|
9
|
+
fun fromReadableMap(
|
|
10
|
+
map: ReadableMap,
|
|
11
|
+
parser: StyleParser,
|
|
12
|
+
): InlineImageStyle {
|
|
13
|
+
val size = parser.toPixelFromDIP(map.getDouble("size").toFloat())
|
|
14
|
+
return InlineImageStyle(size)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class InlineMathStyle(
|
|
6
|
+
val color: Int,
|
|
7
|
+
) {
|
|
8
|
+
companion object {
|
|
9
|
+
fun fromReadableMap(
|
|
10
|
+
map: ReadableMap,
|
|
11
|
+
parser: StyleParser,
|
|
12
|
+
): InlineMathStyle {
|
|
13
|
+
val color = parser.parseColor(map, "color")
|
|
14
|
+
return InlineMathStyle(color)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.facebook.react.bridge.ReadableType
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What a pill shows: the variant's default, or one specific link's override keyed by
|
|
8
|
+
* exact URL in the `linkPillContent` prop. Empty strings mean "not set".
|
|
9
|
+
*/
|
|
10
|
+
data class LinkPillContent(
|
|
11
|
+
val label: String = "",
|
|
12
|
+
val iconUri: String = "",
|
|
13
|
+
/** Tint for this link's icon; null means none was set for the link. */
|
|
14
|
+
val iconTintColor: Int? = null,
|
|
15
|
+
) {
|
|
16
|
+
/**
|
|
17
|
+
* Label and icon unset here take their value from [fallback]. The tint is left alone:
|
|
18
|
+
* a variant's tint is for the variant's own icon, so the span decides when it applies.
|
|
19
|
+
*/
|
|
20
|
+
fun orElse(fallback: LinkPillContent) =
|
|
21
|
+
copy(
|
|
22
|
+
label = label.ifEmpty { fallback.label },
|
|
23
|
+
iconUri = iconUri.ifEmpty { fallback.iconUri },
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
companion object {
|
|
27
|
+
fun fromReadableMap(map: ReadableMap): LinkPillContent {
|
|
28
|
+
val hasTint = map.hasKey("iconTintColor") && map.getType("iconTintColor") == ReadableType.Number
|
|
29
|
+
return LinkPillContent(
|
|
30
|
+
label = map.getString("label") ?: "",
|
|
31
|
+
iconUri = map.getString("iconUri") ?: "",
|
|
32
|
+
iconTintColor = if (hasTint) map.getDouble("iconTintColor").toInt() else null,
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import android.graphics.ColorFilter
|
|
5
|
+
import android.graphics.PorterDuff
|
|
6
|
+
import android.graphics.PorterDuffColorFilter
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap
|
|
8
|
+
|
|
9
|
+
/** Geometry and default content of a variant's pill. Dimensions are in pixels. */
|
|
10
|
+
data class LinkPillStyle(
|
|
11
|
+
val content: LinkPillContent = LinkPillContent(),
|
|
12
|
+
val borderRadius: Float = 8f,
|
|
13
|
+
val paddingHorizontal: Float = 6f,
|
|
14
|
+
val paddingVertical: Float = 2f,
|
|
15
|
+
/** Minimum line height of a block that holds the pill; 0 when unset. */
|
|
16
|
+
val lineHeight: Float = 0f,
|
|
17
|
+
val borderWidth: Float = 0f,
|
|
18
|
+
val borderColor: Int = Color.TRANSPARENT,
|
|
19
|
+
val maxWidth: Float = 0f,
|
|
20
|
+
) {
|
|
21
|
+
/** Replaces the icon's colors and keeps its alpha; shared by every pill of the variant. */
|
|
22
|
+
val iconTint: ColorFilter? = content.iconTintColor?.let { PorterDuffColorFilter(it, PorterDuff.Mode.SRC_IN) }
|
|
23
|
+
|
|
24
|
+
companion object {
|
|
25
|
+
/** Returns null when the variant does not enable pill presentation. */
|
|
26
|
+
fun fromReadableMap(
|
|
27
|
+
map: ReadableMap,
|
|
28
|
+
parser: StyleParser,
|
|
29
|
+
): LinkPillStyle? {
|
|
30
|
+
if (!parser.parseBoolean(map, "enabled")) return null
|
|
31
|
+
return LinkPillStyle(
|
|
32
|
+
content =
|
|
33
|
+
LinkPillContent.fromReadableMap(map).copy(iconTintColor = parser.parseOptionalColor(map, "iconTintColor")),
|
|
34
|
+
borderRadius = parser.toPixelFromDIP(parser.parseOptionalDouble(map, "borderRadius", 8.0).toFloat()),
|
|
35
|
+
paddingHorizontal = parser.toPixelFromDIP(parser.parseOptionalDouble(map, "paddingHorizontal", 6.0).toFloat()),
|
|
36
|
+
paddingVertical = parser.toPixelFromDIP(parser.parseOptionalDouble(map, "paddingVertical", 2.0).toFloat()),
|
|
37
|
+
lineHeight = parser.toPixelFromSP(parser.parseOptionalDouble(map, "lineHeight").toFloat()),
|
|
38
|
+
borderWidth = parser.toPixelFromDIP(parser.parseOptionalDouble(map, "borderWidth").toFloat()),
|
|
39
|
+
borderColor = parser.parseOptionalColor(map, "borderColor") ?: Color.TRANSPARENT,
|
|
40
|
+
maxWidth = parser.toPixelFromDIP(parser.parseOptionalDouble(map, "maxWidth").toFloat()),
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class LinkStyle(
|
|
6
|
+
val fontFamily: String,
|
|
7
|
+
val color: Int,
|
|
8
|
+
val underline: Boolean,
|
|
9
|
+
val backgroundColor: Int,
|
|
10
|
+
) {
|
|
11
|
+
companion object {
|
|
12
|
+
fun fromReadableMap(
|
|
13
|
+
map: ReadableMap,
|
|
14
|
+
parser: StyleParser,
|
|
15
|
+
): LinkStyle {
|
|
16
|
+
val fontFamily = parser.parseString(map, "fontFamily")
|
|
17
|
+
val color = parser.parseColor(map, "color")
|
|
18
|
+
val underline = map.getBoolean("underline")
|
|
19
|
+
val backgroundColor = parser.parseColor(map, "backgroundColor")
|
|
20
|
+
return LinkStyle(fontFamily, color, underline, backgroundColor)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|