@mathers101/react-native-render-rich-text 0.1.9 → 0.1.14
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 -20
- package/README.md +140 -140
- package/ReactNativeRenderRichText.podspec +23 -23
- package/android/build.gradle +86 -86
- package/android/consumer-rules.pro +3 -3
- package/android/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/java/com/renderrichtext/EnrichedTiptapTextLayoutManager.kt +24 -24
- package/android/src/main/java/com/renderrichtext/EnrichedTiptapTextPackage.kt +13 -13
- package/android/src/main/java/com/renderrichtext/MeasurementStore.kt +644 -644
- package/android/src/main/java/com/renderrichtext/accessibility/AccessibilityLabels.kt +17 -17
- package/android/src/main/java/com/renderrichtext/accessibility/AccessibleTiptapTextView.kt +112 -112
- package/android/src/main/java/com/renderrichtext/accessibility/TiptapAccessibilityHelper.kt +576 -576
- package/android/src/main/java/com/renderrichtext/events/CodeBlockPressEvent.kt +24 -24
- package/android/src/main/java/com/renderrichtext/events/ContextMenuItemPressEvent.kt +28 -28
- package/android/src/main/java/com/renderrichtext/events/CopyPressEvent.kt +24 -24
- package/android/src/main/java/com/renderrichtext/events/ImagePressEvent.kt +25 -25
- package/android/src/main/java/com/renderrichtext/events/LatexErrorEvent.kt +29 -29
- package/android/src/main/java/com/renderrichtext/events/LinkLongPressEvent.kt +23 -23
- package/android/src/main/java/com/renderrichtext/events/LinkPressEvent.kt +23 -23
- package/android/src/main/java/com/renderrichtext/events/MentionLongPressEvent.kt +25 -25
- package/android/src/main/java/com/renderrichtext/events/MentionPressEvent.kt +25 -25
- package/android/src/main/java/com/renderrichtext/events/TaskListItemPressEvent.kt +26 -26
- package/android/src/main/java/com/renderrichtext/math/LatexErrorReporter.kt +9 -9
- package/android/src/main/java/com/renderrichtext/parser/Parser.kt +59 -59
- package/android/src/main/java/com/renderrichtext/parser/TextLinkMatching.kt +35 -35
- package/android/src/main/java/com/renderrichtext/renderer/BaselineShiftRenderer.kt +45 -45
- package/android/src/main/java/com/renderrichtext/renderer/BlankLineRenderer.kt +39 -39
- package/android/src/main/java/com/renderrichtext/renderer/BlockquoteRenderer.kt +243 -243
- package/android/src/main/java/com/renderrichtext/renderer/BlockquoteTextRenderer.kt +56 -56
- package/android/src/main/java/com/renderrichtext/renderer/CodeBlockRenderer.kt +135 -135
- package/android/src/main/java/com/renderrichtext/renderer/CodeRenderer.kt +37 -37
- package/android/src/main/java/com/renderrichtext/renderer/EmphasisRenderer.kt +28 -28
- package/android/src/main/java/com/renderrichtext/renderer/HeadingRenderer.kt +81 -81
- package/android/src/main/java/com/renderrichtext/renderer/HighlightRenderer.kt +26 -26
- package/android/src/main/java/com/renderrichtext/renderer/LineBreakRenderer.kt +17 -17
- package/android/src/main/java/com/renderrichtext/renderer/LinkRenderer.kt +90 -90
- package/android/src/main/java/com/renderrichtext/renderer/ListContextManager.kt +109 -109
- package/android/src/main/java/com/renderrichtext/renderer/ListItemRenderer.kt +211 -211
- package/android/src/main/java/com/renderrichtext/renderer/ListRenderer.kt +133 -133
- package/android/src/main/java/com/renderrichtext/renderer/MentionRenderer.kt +85 -85
- package/android/src/main/java/com/renderrichtext/renderer/ParagraphRenderer.kt +91 -91
- package/android/src/main/java/com/renderrichtext/renderer/Renderer.kt +148 -148
- package/android/src/main/java/com/renderrichtext/renderer/SoftBreakRenderer.kt +17 -17
- package/android/src/main/java/com/renderrichtext/renderer/SpanStyleCache.kt +143 -143
- package/android/src/main/java/com/renderrichtext/renderer/StrikethroughRenderer.kt +28 -28
- package/android/src/main/java/com/renderrichtext/renderer/StrongRenderer.kt +28 -28
- package/android/src/main/java/com/renderrichtext/renderer/TextRenderer.kt +31 -31
- package/android/src/main/java/com/renderrichtext/renderer/ThematicBreakRenderer.kt +46 -46
- package/android/src/main/java/com/renderrichtext/renderer/UnderlineRenderer.kt +28 -28
- package/android/src/main/java/com/renderrichtext/spans/BaseListSpan.kt +164 -164
- package/android/src/main/java/com/renderrichtext/spans/BaselineShiftSpan.kt +27 -27
- package/android/src/main/java/com/renderrichtext/spans/BlockquoteSpan.kt +302 -302
- package/android/src/main/java/com/renderrichtext/spans/CodeBackgroundSpan.kt +205 -205
- package/android/src/main/java/com/renderrichtext/spans/CodeBlockSpan.kt +216 -216
- package/android/src/main/java/com/renderrichtext/spans/CodeSpan.kt +32 -32
- package/android/src/main/java/com/renderrichtext/spans/EmphasisSpan.kt +42 -42
- package/android/src/main/java/com/renderrichtext/spans/FadeInSpan.kt +29 -29
- package/android/src/main/java/com/renderrichtext/spans/HeadingSpan.kt +38 -38
- package/android/src/main/java/com/renderrichtext/spans/HighlightSpan.kt +80 -80
- package/android/src/main/java/com/renderrichtext/spans/ImageSpan.kt +481 -481
- package/android/src/main/java/com/renderrichtext/spans/InlineBackgroundGeometry.kt +42 -42
- package/android/src/main/java/com/renderrichtext/spans/LineHeightSpan.kt +39 -39
- package/android/src/main/java/com/renderrichtext/spans/LinkPillIconCache.kt +154 -154
- package/android/src/main/java/com/renderrichtext/spans/LinkPillSpan.kt +381 -381
- package/android/src/main/java/com/renderrichtext/spans/LinkSpan.kt +68 -68
- package/android/src/main/java/com/renderrichtext/spans/ListItemSpacingSpan.kt +33 -33
- package/android/src/main/java/com/renderrichtext/spans/ListMarkerAnchorSpan.kt +38 -38
- package/android/src/main/java/com/renderrichtext/spans/MarginBottomSpan.kt +76 -76
- package/android/src/main/java/com/renderrichtext/spans/MentionChipSpan.kt +132 -132
- package/android/src/main/java/com/renderrichtext/spans/MentionSpan.kt +46 -46
- package/android/src/main/java/com/renderrichtext/spans/OrderedListSpan.kt +127 -127
- package/android/src/main/java/com/renderrichtext/spans/SpoilerSpan.kt +33 -33
- package/android/src/main/java/com/renderrichtext/spans/StrikethroughSpan.kt +12 -12
- package/android/src/main/java/com/renderrichtext/spans/StrongSpan.kt +39 -39
- package/android/src/main/java/com/renderrichtext/spans/TaskListSpan.kt +143 -143
- package/android/src/main/java/com/renderrichtext/spans/TextSpan.kt +26 -26
- package/android/src/main/java/com/renderrichtext/spans/ThematicBreakSpan.kt +69 -69
- package/android/src/main/java/com/renderrichtext/spans/UnorderedListSpan.kt +96 -96
- package/android/src/main/java/com/renderrichtext/spoiler/SpoilerStubs.kt +46 -46
- package/android/src/main/java/com/renderrichtext/styles/BaseBlockStyle.kt +11 -11
- package/android/src/main/java/com/renderrichtext/styles/BlockquoteStyle.kt +83 -83
- package/android/src/main/java/com/renderrichtext/styles/CodeBlockStyle.kt +80 -80
- package/android/src/main/java/com/renderrichtext/styles/CodeStyle.kt +26 -26
- package/android/src/main/java/com/renderrichtext/styles/EmphasisStyle.kt +21 -21
- package/android/src/main/java/com/renderrichtext/styles/FactoidStyle.kt +21 -21
- package/android/src/main/java/com/renderrichtext/styles/HeadingStyle.kt +33 -33
- package/android/src/main/java/com/renderrichtext/styles/HighlightStyle.kt +19 -19
- package/android/src/main/java/com/renderrichtext/styles/ImageStyle.kt +29 -29
- package/android/src/main/java/com/renderrichtext/styles/InlineImageStyle.kt +17 -17
- package/android/src/main/java/com/renderrichtext/styles/InlineMathStyle.kt +17 -17
- package/android/src/main/java/com/renderrichtext/styles/LinkPillContent.kt +36 -36
- package/android/src/main/java/com/renderrichtext/styles/LinkPillStyle.kt +44 -44
- package/android/src/main/java/com/renderrichtext/styles/LinkStyle.kt +23 -23
- package/android/src/main/java/com/renderrichtext/styles/LinkVariantEntry.kt +34 -34
- package/android/src/main/java/com/renderrichtext/styles/ListStyle.kt +65 -65
- package/android/src/main/java/com/renderrichtext/styles/MathStyle.kt +29 -29
- package/android/src/main/java/com/renderrichtext/styles/MentionStyle.kt +19 -19
- package/android/src/main/java/com/renderrichtext/styles/ParagraphStyle.kt +33 -33
- package/android/src/main/java/com/renderrichtext/styles/SpoilerStyle.kt +27 -27
- package/android/src/main/java/com/renderrichtext/styles/StrikethroughStyle.kt +17 -17
- package/android/src/main/java/com/renderrichtext/styles/StrongStyle.kt +21 -21
- package/android/src/main/java/com/renderrichtext/styles/StyleConfig.kt +411 -411
- package/android/src/main/java/com/renderrichtext/styles/StyleParser.kt +92 -92
- package/android/src/main/java/com/renderrichtext/styles/SubscriptStyle.kt +16 -16
- package/android/src/main/java/com/renderrichtext/styles/SuperscriptStyle.kt +16 -16
- package/android/src/main/java/com/renderrichtext/styles/TableStyle.kt +75 -75
- package/android/src/main/java/com/renderrichtext/styles/TaskListStyle.kt +29 -29
- package/android/src/main/java/com/renderrichtext/styles/TextAlignment.kt +32 -32
- package/android/src/main/java/com/renderrichtext/styles/ThematicBreakStyle.kt +23 -23
- package/android/src/main/java/com/renderrichtext/styles/UnderlineStyle.kt +17 -17
- package/android/src/main/java/com/renderrichtext/styles/VideoStyle.kt +31 -31
- package/android/src/main/java/com/renderrichtext/utils/common/BorderStyleUtils.kt +86 -86
- package/android/src/main/java/com/renderrichtext/utils/common/BreakStrategyUtils.kt +32 -32
- package/android/src/main/java/com/renderrichtext/utils/common/CodeBlockHighlighter.kt +36 -36
- package/android/src/main/java/com/renderrichtext/utils/common/CodeBlockNode.kt +42 -42
- package/android/src/main/java/com/renderrichtext/utils/common/EllipsizeUtils.kt +27 -27
- package/android/src/main/java/com/renderrichtext/utils/common/EnrichedTiptapAncestorUtils.kt +10 -10
- package/android/src/main/java/com/renderrichtext/utils/common/FeatureFlags.kt +9 -9
- package/android/src/main/java/com/renderrichtext/utils/common/LinkRecognitionProps.kt +31 -31
- package/android/src/main/java/com/renderrichtext/utils/common/LinkRegexConfig.kt +56 -56
- package/android/src/main/java/com/renderrichtext/utils/common/MotionPreferences.kt +18 -18
- package/android/src/main/java/com/renderrichtext/utils/common/ReadableMapExtensions.kt +28 -28
- package/android/src/main/java/com/renderrichtext/utils/common/layout/RTLUtils.kt +6 -6
- package/android/src/main/java/com/renderrichtext/utils/common/serialization/TiptapASTSerializer.kt +368 -368
- package/android/src/main/java/com/renderrichtext/utils/text/ImageCache.kt +88 -88
- package/android/src/main/java/com/renderrichtext/utils/text/ImageDownloader.kt +203 -203
- package/android/src/main/java/com/renderrichtext/utils/text/LocalImageLoader.kt +167 -167
- package/android/src/main/java/com/renderrichtext/utils/text/TailFadeInAnimator.kt +84 -84
- package/android/src/main/java/com/renderrichtext/utils/text/conversion/HTMLGenerator.kt +1105 -1105
- package/android/src/main/java/com/renderrichtext/utils/text/conversion/TiptapExtractor.kt +423 -423
- package/android/src/main/java/com/renderrichtext/utils/text/extensions/ParagraphUtils.kt +9 -9
- package/android/src/main/java/com/renderrichtext/utils/text/extensions/SpannableExtensions.kt +9 -9
- package/android/src/main/java/com/renderrichtext/utils/text/extensions/TextPaintExtensions.kt +76 -76
- package/android/src/main/java/com/renderrichtext/utils/text/interaction/CheckboxTouchHelper.kt +61 -61
- package/android/src/main/java/com/renderrichtext/utils/text/interaction/TaskListTapUtils.kt +286 -286
- package/android/src/main/java/com/renderrichtext/utils/text/span/ApplyLineHeight.kt +39 -39
- package/android/src/main/java/com/renderrichtext/utils/text/span/BlockSpacing.kt +142 -142
- package/android/src/main/java/com/renderrichtext/utils/text/span/SpanFlags.kt +43 -43
- package/android/src/main/java/com/renderrichtext/utils/text/span/WidthAwareSpans.kt +30 -30
- package/android/src/main/java/com/renderrichtext/utils/text/view/CodeBlockPressHost.kt +15 -15
- package/android/src/main/java/com/renderrichtext/utils/text/view/ImagePressHost.kt +19 -19
- package/android/src/main/java/com/renderrichtext/utils/text/view/SelectionActionMode.kt +235 -235
- package/android/src/main/java/com/renderrichtext/utils/text/view/TextSelectionColors.kt +48 -48
- package/android/src/main/java/com/renderrichtext/utils/text/view/TextViewSetup.kt +119 -119
- package/android/src/main/java/com/renderrichtext/views/ContextMenuPopup.kt +217 -217
- package/android/src/main/java/com/renderrichtext/views/CopyGlyph.kt +101 -101
- package/android/src/main/java/com/renderrichtext/views/WrapGlyph.kt +40 -40
- package/android/src/main/jni/CMakeLists.txt +52 -52
- package/android/src/main/jni/react/renderer/components/RichTextSpec/ComponentDescriptors.h +30 -30
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextComponentDescriptor.h +29 -29
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextMeasurementManager.cpp +45 -45
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextMeasurementManager.h +21 -21
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextShadowNode.cpp +38 -38
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextShadowNode.h +53 -53
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextState.cpp +9 -9
- package/android/src/main/jni/react/renderer/components/RichTextSpec/TiptapTextState.h +24 -24
- package/android/src/main/jni/react/renderer/components/RichTextSpec/conversions.h +40 -40
- package/cpp/parser/TiptapParser.hpp +13 -13
- package/cpp/vendor/nlohmann/json.hpp +24765 -24765
- package/ios/EnrichedTiptapText.h +27 -27
- package/ios/attachments/ENRMImageAttachment.h +51 -51
- package/ios/attachments/ENRMImageAttachment.m +398 -398
- package/ios/attachments/ENRMLinkPillAttachment.h +47 -47
- package/ios/attachments/ENRMLinkPillAttachment.m +324 -324
- package/ios/attachments/ENRMLinkPillIconCache.h +28 -28
- package/ios/attachments/ENRMLinkPillIconCache.m +181 -181
- package/ios/attachments/ENRMLinkPillText.h +27 -27
- package/ios/attachments/ENRMLinkPillText.m +118 -118
- package/ios/attachments/ENRMMathInlineAttachment.h +7 -7
- package/ios/attachments/ENRMMathInlineAttachment.m +4 -4
- package/ios/attachments/ThematicBreakAttachment.h +15 -15
- package/ios/attachments/ThematicBreakAttachment.m +33 -33
- package/ios/internals/ENRMViewFreeMeasurement.h +208 -208
- package/ios/internals/EnrichedTiptapTextComponentDescriptor.h +19 -19
- package/ios/internals/EnrichedTiptapTextShadowNode.h +43 -43
- package/ios/internals/EnrichedTiptapTextShadowNode.mm +69 -69
- package/ios/internals/EnrichedTiptapTextState.h +24 -24
- package/ios/internals/MeasurementCache.h +308 -308
- package/ios/internals/ShadowMeasurementUtils.h +145 -145
- package/ios/parser/ENRMTextLinkAttributes.h +7 -7
- package/ios/parser/ENRMTiptapParser.h +33 -33
- package/ios/parser/ENRMTiptapParser.mm +73 -73
- package/ios/parser/TiptapASTNode.m +52 -52
- package/ios/renderer/AttributedRenderer.h +23 -23
- package/ios/renderer/AttributedRenderer.m +229 -229
- package/ios/renderer/BaseRenderer.h +33 -33
- package/ios/renderer/BaseRenderer.m +46 -46
- package/ios/renderer/BaselineShiftTextAttributes.h +10 -10
- package/ios/renderer/BaselineShiftTextAttributes.m +26 -26
- package/ios/renderer/BlankLineRenderer.h +4 -4
- package/ios/renderer/BlankLineRenderer.m +51 -51
- package/ios/renderer/BlockquoteRenderer.h +6 -6
- package/ios/renderer/BlockquoteRenderer.m +258 -258
- package/ios/renderer/CodeBlockRenderer.h +9 -9
- package/ios/renderer/CodeBlockRenderer.m +99 -99
- package/ios/renderer/CodeRenderer.h +9 -9
- package/ios/renderer/CodeRenderer.m +69 -69
- package/ios/renderer/ENRMBlockquoteTextRenderer.h +25 -25
- package/ios/renderer/ENRMBlockquoteTextRenderer.m +48 -48
- package/ios/renderer/EmphasisRenderer.h +5 -5
- package/ios/renderer/EmphasisRenderer.m +99 -99
- package/ios/renderer/HeadingRenderer.h +6 -6
- package/ios/renderer/HeadingRenderer.m +102 -102
- package/ios/renderer/HighlightRenderer.h +7 -7
- package/ios/renderer/HighlightRenderer.m +33 -33
- package/ios/renderer/LinkRenderer.h +6 -6
- package/ios/renderer/LinkRenderer.m +157 -157
- package/ios/renderer/ListItemRenderer.h +24 -24
- package/ios/renderer/ListItemRenderer.m +283 -283
- package/ios/renderer/ListRenderer.h +13 -13
- package/ios/renderer/ListRenderer.m +126 -126
- package/ios/renderer/MentionRenderer.h +9 -9
- package/ios/renderer/MentionRenderer.m +96 -96
- package/ios/renderer/NodeRenderer.h +8 -8
- package/ios/renderer/ParagraphRenderer.h +6 -6
- package/ios/renderer/ParagraphRenderer.m +85 -85
- package/ios/renderer/RenderContext.h +145 -145
- package/ios/renderer/RenderContext.m +402 -402
- package/ios/renderer/RendererFactory.h +12 -12
- package/ios/renderer/StrikethroughRenderer.h +5 -5
- package/ios/renderer/StrikethroughRenderer.m +30 -30
- package/ios/renderer/StrongRenderer.h +5 -5
- package/ios/renderer/StrongRenderer.m +87 -87
- package/ios/renderer/TextRenderer.h +6 -6
- package/ios/renderer/TextRenderer.m +18 -18
- package/ios/renderer/ThematicBreakRenderer.h +4 -4
- package/ios/renderer/ThematicBreakRenderer.m +41 -41
- package/ios/renderer/UnderlineRenderer.h +4 -4
- package/ios/renderer/UnderlineRenderer.m +41 -41
- package/ios/styles/ENRMFontSlot.h +12 -12
- package/ios/styles/ENRMFontSlot.m +24 -24
- package/ios/styles/StyleConfig.h +488 -488
- package/ios/styles/StyleConfig.mm +2820 -2820
- package/ios/utils/AccessibilityInfo.h +35 -35
- package/ios/utils/AccessibilityInfo.m +24 -24
- package/ios/utils/BlockquoteBorder.h +26 -26
- package/ios/utils/BlockquoteBorder.m +294 -294
- package/ios/utils/CodeBackground.h +19 -19
- package/ios/utils/CodeBackground.m +196 -196
- package/ios/utils/CodeBlockBackground.h +17 -17
- package/ios/utils/CodeBlockBackground.m +102 -102
- package/ios/utils/ContextMenuUtils.h +76 -76
- package/ios/utils/ContextMenuUtils.mm +75 -75
- package/ios/utils/ENRMAccessibilityLabels.h +40 -40
- package/ios/utils/ENRMAccessibilityLabels.m +5 -5
- package/ios/utils/ENRMAsyncRenderCoordinator.h +24 -24
- package/ios/utils/ENRMAsyncRenderCoordinator.m +37 -37
- package/ios/utils/ENRMAtomicSize.h +65 -65
- package/ios/utils/ENRMCodeBlockContent.h +37 -37
- package/ios/utils/ENRMCodeBlockContent.mm +89 -89
- package/ios/utils/ENRMFeatureFlags.h +25 -25
- package/ios/utils/ENRMImageDownloader.h +30 -30
- package/ios/utils/ENRMImageDownloader.m +168 -168
- package/ios/utils/ENRMLatexErrorCoordinator.h +27 -27
- package/ios/utils/ENRMLatexErrorCoordinator.mm +75 -75
- package/ios/utils/ENRMLatexErrorReporting.h +13 -13
- package/ios/utils/ENRMLinkContextMenus.h +93 -93
- package/ios/utils/ENRMLinkContextMenus.m +178 -178
- package/ios/utils/ENRMLinkRegexConfig.h +30 -30
- package/ios/utils/ENRMLinkRegexConfig.mm +104 -104
- package/ios/utils/ENRMLinkRegexProps.h +23 -23
- package/ios/utils/ENRMLocalImageLoader.h +35 -35
- package/ios/utils/ENRMLocalImageLoader.m +111 -111
- package/ios/utils/ENRMMenuAction.h +27 -27
- package/ios/utils/ENRMMenuAction.m +33 -33
- package/ios/utils/ENRMSpoilerOverlayManager.h +15 -15
- package/ios/utils/ENRMSpoilerOverlayManager.m +19 -19
- package/ios/utils/ENRMSpoilerTapUtils.h +6 -6
- package/ios/utils/ENRMSpoilerTapUtils.m +11 -11
- package/ios/utils/ENRMTailFadeInAnimator.h +16 -16
- package/ios/utils/ENRMTailFadeInAnimator.m +161 -161
- package/ios/utils/ENRMTextHitTest.h +23 -23
- package/ios/utils/ENRMTextHitTest.m +20 -20
- package/ios/utils/ENRMTextInteractionUtils.h +20 -20
- package/ios/utils/ENRMTextInteractionUtils.m +15 -15
- package/ios/utils/ENRMTextRenderer.h +38 -38
- package/ios/utils/ENRMTextRenderer.m +54 -54
- package/ios/utils/ENRMTextViewSetup.h +132 -132
- package/ios/utils/ENRMUIKit.h +429 -429
- package/ios/utils/EditMenuUtils.h +105 -105
- package/ios/utils/EditMenuUtils.m +143 -143
- package/ios/utils/FontScaleObserver.h +10 -10
- package/ios/utils/FontScaleObserver.m +55 -55
- package/ios/utils/FontUtils.h +31 -31
- package/ios/utils/FontUtils.m +63 -63
- package/ios/utils/HTMLGenerator.h +25 -25
- package/ios/utils/HTMLGenerator.m +1041 -1041
- package/ios/utils/HeightUpdateUtils.h +25 -25
- package/ios/utils/ImageRequestHeaderUtils.h +35 -35
- package/ios/utils/LastElementUtils.h +97 -97
- package/ios/utils/LinkContextMenuUtils.h +55 -55
- package/ios/utils/LinkPillContentUtils.h +46 -46
- package/ios/utils/ListMarkerDrawer.h +15 -15
- package/ios/utils/ListMarkerDrawer.m +239 -239
- package/ios/utils/MentionBackground.h +26 -26
- package/ios/utils/MentionBackground.m +86 -86
- package/ios/utils/ParagraphStyleUtils.h +87 -87
- package/ios/utils/ParagraphStyleUtils.m +484 -484
- package/ios/utils/PasteboardUtils.h +48 -48
- package/ios/utils/PasteboardUtils.m +166 -166
- package/ios/utils/RTFExportUtils.h +24 -24
- package/ios/utils/RTFExportUtils.m +299 -299
- package/ios/utils/SelectionColorUtils.h +14 -14
- package/ios/utils/StylePropsUtils.h +1340 -1340
- package/ios/utils/TaskListTapUtils.h +6 -6
- package/ios/utils/TaskListTapUtils.m +14 -14
- package/ios/utils/TextViewLayoutManager.h +14 -14
- package/ios/utils/TiptapAccessibilityElementBuilder.h +43 -43
- package/ios/utils/TiptapAccessibilityElementBuilder.m +432 -432
- package/ios/utils/TiptapExtractor.h +17 -17
- package/ios/utils/TiptapExtractor.m +367 -367
- package/ios/views/ENRMTiptapTextView.h +25 -25
- package/ios/views/ENRMTiptapTextView.m +247 -247
- package/package.json +65 -70
- package/react-native.config.js +10 -10
- package/src/admonitionDefaults.ts +58 -58
- package/src/darkModeTextStyle.ts +99 -99
- package/src/headingDefaults.ts +21 -21
- package/src/index.tsx +4 -4
- package/src/linkVariantUtils.ts +120 -120
- package/src/normalizeTiptapStyle.ts +397 -397
- package/src/rn-globals.d.ts +1 -1
- package/src/styleUtils.ts +107 -107
- package/src/types/TiptapStyle.ts +532 -532
- package/src/types/TiptapStyleInternal.ts +299 -299
- package/src/types/linkPill.ts +9 -9
- package/src/utils/isDev.ts +4 -4
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
package com.renderrichtext.styles
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReadableMap
|
|
4
|
-
|
|
5
|
-
data class VideoStyle(
|
|
6
|
-
val marginTop: Float,
|
|
7
|
-
val marginBottom: Float,
|
|
8
|
-
val borderRadius: Float,
|
|
9
|
-
val aspectRatio: Float,
|
|
10
|
-
val backgroundColor: Int,
|
|
11
|
-
) {
|
|
12
|
-
/** Aspect ratio guaranteed to be positive. Falls back to 16:9 if the raw value is ≤ 0. */
|
|
13
|
-
val resolvedAspectRatio: Float
|
|
14
|
-
get() = if (aspectRatio > 0f) aspectRatio else DEFAULT_ASPECT_RATIO
|
|
15
|
-
|
|
16
|
-
companion object {
|
|
17
|
-
private const val DEFAULT_ASPECT_RATIO = 16f / 9f
|
|
18
|
-
|
|
19
|
-
fun fromReadableMap(
|
|
20
|
-
map: ReadableMap,
|
|
21
|
-
parser: StyleParser,
|
|
22
|
-
): VideoStyle {
|
|
23
|
-
val marginTop = parser.toPixelFromDIP(map.getDouble("marginTop").toFloat())
|
|
24
|
-
val marginBottom = parser.toPixelFromDIP(map.getDouble("marginBottom").toFloat())
|
|
25
|
-
val borderRadius = parser.toPixelFromDIP(map.getDouble("borderRadius").toFloat())
|
|
26
|
-
val aspectRatio = map.getDouble("aspectRatio").toFloat()
|
|
27
|
-
val backgroundColor = parser.parseColor(map, "backgroundColor")
|
|
28
|
-
return VideoStyle(marginTop, marginBottom, borderRadius, aspectRatio, backgroundColor)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
package com.renderrichtext.styles
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class VideoStyle(
|
|
6
|
+
val marginTop: Float,
|
|
7
|
+
val marginBottom: Float,
|
|
8
|
+
val borderRadius: Float,
|
|
9
|
+
val aspectRatio: Float,
|
|
10
|
+
val backgroundColor: Int,
|
|
11
|
+
) {
|
|
12
|
+
/** Aspect ratio guaranteed to be positive. Falls back to 16:9 if the raw value is ≤ 0. */
|
|
13
|
+
val resolvedAspectRatio: Float
|
|
14
|
+
get() = if (aspectRatio > 0f) aspectRatio else DEFAULT_ASPECT_RATIO
|
|
15
|
+
|
|
16
|
+
companion object {
|
|
17
|
+
private const val DEFAULT_ASPECT_RATIO = 16f / 9f
|
|
18
|
+
|
|
19
|
+
fun fromReadableMap(
|
|
20
|
+
map: ReadableMap,
|
|
21
|
+
parser: StyleParser,
|
|
22
|
+
): VideoStyle {
|
|
23
|
+
val marginTop = parser.toPixelFromDIP(map.getDouble("marginTop").toFloat())
|
|
24
|
+
val marginBottom = parser.toPixelFromDIP(map.getDouble("marginBottom").toFloat())
|
|
25
|
+
val borderRadius = parser.toPixelFromDIP(map.getDouble("borderRadius").toFloat())
|
|
26
|
+
val aspectRatio = map.getDouble("aspectRatio").toFloat()
|
|
27
|
+
val backgroundColor = parser.parseColor(map, "backgroundColor")
|
|
28
|
+
return VideoStyle(marginTop, marginBottom, borderRadius, aspectRatio, backgroundColor)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
package com.renderrichtext.utils.common
|
|
2
|
-
|
|
3
|
-
import android.view.View
|
|
4
|
-
import com.facebook.react.bridge.ColorPropConverter
|
|
5
|
-
import com.facebook.react.uimanager.BackgroundStyleApplicator
|
|
6
|
-
import com.facebook.react.uimanager.LengthPercentage
|
|
7
|
-
import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
8
|
-
import com.facebook.react.uimanager.style.BorderRadiusProp
|
|
9
|
-
import com.facebook.react.uimanager.style.BorderStyle
|
|
10
|
-
import com.facebook.react.uimanager.style.LogicalEdge
|
|
11
|
-
|
|
12
|
-
// BaseViewManagerDelegate (used by our SimpleViewManagers) ignores border
|
|
13
|
-
// width/color/style and no-ops borderRadius, so `containerStyle` borders vanish on
|
|
14
|
-
// Android. Replay them via BackgroundStyleApplicator like ReactViewManager does.
|
|
15
|
-
// Call after super.updateProperties so the composite background drawable exists.
|
|
16
|
-
fun applyReactBorderProps(
|
|
17
|
-
view: View,
|
|
18
|
-
props: ReactStylesDiffMap,
|
|
19
|
-
) {
|
|
20
|
-
for ((name, edge) in BORDER_WIDTH_EDGES) {
|
|
21
|
-
if (!props.hasKey(name)) continue
|
|
22
|
-
val width = if (props.isNull(name)) null else props.getFloat(name, Float.NaN).takeUnless { it.isNaN() }
|
|
23
|
-
BackgroundStyleApplicator.setBorderWidth(view, edge, width)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (BORDER_COLOR_EDGES.keys.any { props.hasKey(it) }) {
|
|
27
|
-
val rawProps = props.toMap()
|
|
28
|
-
for ((name, edge) in BORDER_COLOR_EDGES) {
|
|
29
|
-
if (!props.hasKey(name)) continue
|
|
30
|
-
val color = if (props.isNull(name)) null else ColorPropConverter.getColor(rawProps[name], view.context)
|
|
31
|
-
BackgroundStyleApplicator.setBorderColor(view, edge, color)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (props.hasKey("borderStyle")) {
|
|
36
|
-
val style = if (props.isNull("borderStyle")) null else BorderStyle.fromString(props.getString("borderStyle") ?: "")
|
|
37
|
-
BackgroundStyleApplicator.setBorderStyle(view, style)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Radius last, so the border drawable created above already exists and picks
|
|
41
|
-
// up the rounded corners.
|
|
42
|
-
for ((name, corner) in BORDER_RADIUS_PROPS) {
|
|
43
|
-
if (!props.hasKey(name)) continue
|
|
44
|
-
val radius = if (props.isNull(name)) null else LengthPercentage.setFromDynamic(props.getDynamic(name))
|
|
45
|
-
BackgroundStyleApplicator.setBorderRadius(view, corner, radius)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private val BORDER_WIDTH_EDGES =
|
|
50
|
-
linkedMapOf(
|
|
51
|
-
"borderWidth" to LogicalEdge.ALL,
|
|
52
|
-
"borderLeftWidth" to LogicalEdge.LEFT,
|
|
53
|
-
"borderRightWidth" to LogicalEdge.RIGHT,
|
|
54
|
-
"borderTopWidth" to LogicalEdge.TOP,
|
|
55
|
-
"borderBottomWidth" to LogicalEdge.BOTTOM,
|
|
56
|
-
"borderStartWidth" to LogicalEdge.START,
|
|
57
|
-
"borderEndWidth" to LogicalEdge.END,
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
private val BORDER_COLOR_EDGES =
|
|
61
|
-
linkedMapOf(
|
|
62
|
-
"borderColor" to LogicalEdge.ALL,
|
|
63
|
-
"borderLeftColor" to LogicalEdge.LEFT,
|
|
64
|
-
"borderRightColor" to LogicalEdge.RIGHT,
|
|
65
|
-
"borderTopColor" to LogicalEdge.TOP,
|
|
66
|
-
"borderBottomColor" to LogicalEdge.BOTTOM,
|
|
67
|
-
"borderStartColor" to LogicalEdge.START,
|
|
68
|
-
"borderEndColor" to LogicalEdge.END,
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
private val BORDER_RADIUS_PROPS =
|
|
72
|
-
linkedMapOf(
|
|
73
|
-
"borderRadius" to BorderRadiusProp.BORDER_RADIUS,
|
|
74
|
-
"borderTopLeftRadius" to BorderRadiusProp.BORDER_TOP_LEFT_RADIUS,
|
|
75
|
-
"borderTopRightRadius" to BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS,
|
|
76
|
-
"borderBottomRightRadius" to BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS,
|
|
77
|
-
"borderBottomLeftRadius" to BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS,
|
|
78
|
-
"borderTopStartRadius" to BorderRadiusProp.BORDER_TOP_START_RADIUS,
|
|
79
|
-
"borderTopEndRadius" to BorderRadiusProp.BORDER_TOP_END_RADIUS,
|
|
80
|
-
"borderBottomStartRadius" to BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
|
|
81
|
-
"borderBottomEndRadius" to BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
|
|
82
|
-
"borderEndEndRadius" to BorderRadiusProp.BORDER_END_END_RADIUS,
|
|
83
|
-
"borderEndStartRadius" to BorderRadiusProp.BORDER_END_START_RADIUS,
|
|
84
|
-
"borderStartEndRadius" to BorderRadiusProp.BORDER_START_END_RADIUS,
|
|
85
|
-
"borderStartStartRadius" to BorderRadiusProp.BORDER_START_START_RADIUS,
|
|
86
|
-
)
|
|
1
|
+
package com.renderrichtext.utils.common
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.facebook.react.bridge.ColorPropConverter
|
|
5
|
+
import com.facebook.react.uimanager.BackgroundStyleApplicator
|
|
6
|
+
import com.facebook.react.uimanager.LengthPercentage
|
|
7
|
+
import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
8
|
+
import com.facebook.react.uimanager.style.BorderRadiusProp
|
|
9
|
+
import com.facebook.react.uimanager.style.BorderStyle
|
|
10
|
+
import com.facebook.react.uimanager.style.LogicalEdge
|
|
11
|
+
|
|
12
|
+
// BaseViewManagerDelegate (used by our SimpleViewManagers) ignores border
|
|
13
|
+
// width/color/style and no-ops borderRadius, so `containerStyle` borders vanish on
|
|
14
|
+
// Android. Replay them via BackgroundStyleApplicator like ReactViewManager does.
|
|
15
|
+
// Call after super.updateProperties so the composite background drawable exists.
|
|
16
|
+
fun applyReactBorderProps(
|
|
17
|
+
view: View,
|
|
18
|
+
props: ReactStylesDiffMap,
|
|
19
|
+
) {
|
|
20
|
+
for ((name, edge) in BORDER_WIDTH_EDGES) {
|
|
21
|
+
if (!props.hasKey(name)) continue
|
|
22
|
+
val width = if (props.isNull(name)) null else props.getFloat(name, Float.NaN).takeUnless { it.isNaN() }
|
|
23
|
+
BackgroundStyleApplicator.setBorderWidth(view, edge, width)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (BORDER_COLOR_EDGES.keys.any { props.hasKey(it) }) {
|
|
27
|
+
val rawProps = props.toMap()
|
|
28
|
+
for ((name, edge) in BORDER_COLOR_EDGES) {
|
|
29
|
+
if (!props.hasKey(name)) continue
|
|
30
|
+
val color = if (props.isNull(name)) null else ColorPropConverter.getColor(rawProps[name], view.context)
|
|
31
|
+
BackgroundStyleApplicator.setBorderColor(view, edge, color)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (props.hasKey("borderStyle")) {
|
|
36
|
+
val style = if (props.isNull("borderStyle")) null else BorderStyle.fromString(props.getString("borderStyle") ?: "")
|
|
37
|
+
BackgroundStyleApplicator.setBorderStyle(view, style)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Radius last, so the border drawable created above already exists and picks
|
|
41
|
+
// up the rounded corners.
|
|
42
|
+
for ((name, corner) in BORDER_RADIUS_PROPS) {
|
|
43
|
+
if (!props.hasKey(name)) continue
|
|
44
|
+
val radius = if (props.isNull(name)) null else LengthPercentage.setFromDynamic(props.getDynamic(name))
|
|
45
|
+
BackgroundStyleApplicator.setBorderRadius(view, corner, radius)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private val BORDER_WIDTH_EDGES =
|
|
50
|
+
linkedMapOf(
|
|
51
|
+
"borderWidth" to LogicalEdge.ALL,
|
|
52
|
+
"borderLeftWidth" to LogicalEdge.LEFT,
|
|
53
|
+
"borderRightWidth" to LogicalEdge.RIGHT,
|
|
54
|
+
"borderTopWidth" to LogicalEdge.TOP,
|
|
55
|
+
"borderBottomWidth" to LogicalEdge.BOTTOM,
|
|
56
|
+
"borderStartWidth" to LogicalEdge.START,
|
|
57
|
+
"borderEndWidth" to LogicalEdge.END,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
private val BORDER_COLOR_EDGES =
|
|
61
|
+
linkedMapOf(
|
|
62
|
+
"borderColor" to LogicalEdge.ALL,
|
|
63
|
+
"borderLeftColor" to LogicalEdge.LEFT,
|
|
64
|
+
"borderRightColor" to LogicalEdge.RIGHT,
|
|
65
|
+
"borderTopColor" to LogicalEdge.TOP,
|
|
66
|
+
"borderBottomColor" to LogicalEdge.BOTTOM,
|
|
67
|
+
"borderStartColor" to LogicalEdge.START,
|
|
68
|
+
"borderEndColor" to LogicalEdge.END,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
private val BORDER_RADIUS_PROPS =
|
|
72
|
+
linkedMapOf(
|
|
73
|
+
"borderRadius" to BorderRadiusProp.BORDER_RADIUS,
|
|
74
|
+
"borderTopLeftRadius" to BorderRadiusProp.BORDER_TOP_LEFT_RADIUS,
|
|
75
|
+
"borderTopRightRadius" to BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS,
|
|
76
|
+
"borderBottomRightRadius" to BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS,
|
|
77
|
+
"borderBottomLeftRadius" to BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS,
|
|
78
|
+
"borderTopStartRadius" to BorderRadiusProp.BORDER_TOP_START_RADIUS,
|
|
79
|
+
"borderTopEndRadius" to BorderRadiusProp.BORDER_TOP_END_RADIUS,
|
|
80
|
+
"borderBottomStartRadius" to BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
|
|
81
|
+
"borderBottomEndRadius" to BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
|
|
82
|
+
"borderEndEndRadius" to BorderRadiusProp.BORDER_END_END_RADIUS,
|
|
83
|
+
"borderEndStartRadius" to BorderRadiusProp.BORDER_END_START_RADIUS,
|
|
84
|
+
"borderStartEndRadius" to BorderRadiusProp.BORDER_START_END_RADIUS,
|
|
85
|
+
"borderStartStartRadius" to BorderRadiusProp.BORDER_START_START_RADIUS,
|
|
86
|
+
)
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
package com.renderrichtext.utils.common
|
|
2
|
-
|
|
3
|
-
import android.text.Layout
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Resolves a textBreakStrategy prop value (string) to the integer constant used
|
|
7
|
-
* by StaticLayout.Builder.setBreakStrategy() and TextView.setBreakStrategy().
|
|
8
|
-
*
|
|
9
|
-
* Stateless on purpose: textBreakStrategy is a per-view prop. Storage lives in
|
|
10
|
-
* [com.renderrichtext.MeasurementStore] (per viewId), and each
|
|
11
|
-
* view applies the resolved value to its own TextView. Both measurement and
|
|
12
|
-
* render paths must use the same value — mismatch causes measured line count
|
|
13
|
-
* to differ from the rendered line count, sizing the view incorrectly and
|
|
14
|
-
* causing ScrollingMovementMethod (inherited via LinkMovementMethod) to
|
|
15
|
-
* silently scroll the overflow.
|
|
16
|
-
*
|
|
17
|
-
* Note: call sites in StaticLayout.Builder suppress "WrongConstant" lint. This is
|
|
18
|
-
* intentional - Layout.BREAK_STRATEGY_SIMPLE and LineBreaker.BREAK_STRATEGY_SIMPLE
|
|
19
|
-
* are the same integer (0), but the @IntDef annotation on StaticLayout.Builder
|
|
20
|
-
* .setBreakStrategy() was changed from Layout.* to LineBreaker.* in API 29.
|
|
21
|
-
* The suppression is safe; the Layout.* constants share the same integer values.
|
|
22
|
-
*/
|
|
23
|
-
object BreakStrategyUtils {
|
|
24
|
-
const val DEFAULT_STRATEGY = "highQuality"
|
|
25
|
-
|
|
26
|
-
fun resolveBreakStrategy(strategy: String?): Int =
|
|
27
|
-
when (strategy) {
|
|
28
|
-
"simple" -> Layout.BREAK_STRATEGY_SIMPLE
|
|
29
|
-
"balanced" -> Layout.BREAK_STRATEGY_BALANCED
|
|
30
|
-
else -> Layout.BREAK_STRATEGY_HIGH_QUALITY
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
package com.renderrichtext.utils.common
|
|
2
|
+
|
|
3
|
+
import android.text.Layout
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolves a textBreakStrategy prop value (string) to the integer constant used
|
|
7
|
+
* by StaticLayout.Builder.setBreakStrategy() and TextView.setBreakStrategy().
|
|
8
|
+
*
|
|
9
|
+
* Stateless on purpose: textBreakStrategy is a per-view prop. Storage lives in
|
|
10
|
+
* [com.renderrichtext.MeasurementStore] (per viewId), and each
|
|
11
|
+
* view applies the resolved value to its own TextView. Both measurement and
|
|
12
|
+
* render paths must use the same value — mismatch causes measured line count
|
|
13
|
+
* to differ from the rendered line count, sizing the view incorrectly and
|
|
14
|
+
* causing ScrollingMovementMethod (inherited via LinkMovementMethod) to
|
|
15
|
+
* silently scroll the overflow.
|
|
16
|
+
*
|
|
17
|
+
* Note: call sites in StaticLayout.Builder suppress "WrongConstant" lint. This is
|
|
18
|
+
* intentional - Layout.BREAK_STRATEGY_SIMPLE and LineBreaker.BREAK_STRATEGY_SIMPLE
|
|
19
|
+
* are the same integer (0), but the @IntDef annotation on StaticLayout.Builder
|
|
20
|
+
* .setBreakStrategy() was changed from Layout.* to LineBreaker.* in API 29.
|
|
21
|
+
* The suppression is safe; the Layout.* constants share the same integer values.
|
|
22
|
+
*/
|
|
23
|
+
object BreakStrategyUtils {
|
|
24
|
+
const val DEFAULT_STRATEGY = "highQuality"
|
|
25
|
+
|
|
26
|
+
fun resolveBreakStrategy(strategy: String?): Int =
|
|
27
|
+
when (strategy) {
|
|
28
|
+
"simple" -> Layout.BREAK_STRATEGY_SIMPLE
|
|
29
|
+
"balanced" -> Layout.BREAK_STRATEGY_BALANCED
|
|
30
|
+
else -> Layout.BREAK_STRATEGY_HIGH_QUALITY
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
package com.renderrichtext.utils.common
|
|
2
|
-
|
|
3
|
-
import android.text.Spannable
|
|
4
|
-
import com.renderrichtext.styles.CodeBlockStyle
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Syntax highlighting is not part of this library. Code blocks stay plain
|
|
8
|
-
* monospace; the language attribute is kept on the node and not colored.
|
|
9
|
-
*/
|
|
10
|
-
enum class HighlightTokenType {
|
|
11
|
-
Keyword,
|
|
12
|
-
Operator,
|
|
13
|
-
Punctuation,
|
|
14
|
-
String,
|
|
15
|
-
Number,
|
|
16
|
-
Constant,
|
|
17
|
-
Comment,
|
|
18
|
-
Function,
|
|
19
|
-
Type,
|
|
20
|
-
Variable,
|
|
21
|
-
Property,
|
|
22
|
-
Tag,
|
|
23
|
-
Attribute,
|
|
24
|
-
Embedded,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
object CodeBlockHighlighter {
|
|
28
|
-
fun highlight(
|
|
29
|
-
target: Spannable,
|
|
30
|
-
code: String,
|
|
31
|
-
language: String?,
|
|
32
|
-
style: CodeBlockStyle,
|
|
33
|
-
offset: Int = 0,
|
|
34
|
-
) {
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
package com.renderrichtext.utils.common
|
|
2
|
+
|
|
3
|
+
import android.text.Spannable
|
|
4
|
+
import com.renderrichtext.styles.CodeBlockStyle
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Syntax highlighting is not part of this library. Code blocks stay plain
|
|
8
|
+
* monospace; the language attribute is kept on the node and not colored.
|
|
9
|
+
*/
|
|
10
|
+
enum class HighlightTokenType {
|
|
11
|
+
Keyword,
|
|
12
|
+
Operator,
|
|
13
|
+
Punctuation,
|
|
14
|
+
String,
|
|
15
|
+
Number,
|
|
16
|
+
Constant,
|
|
17
|
+
Comment,
|
|
18
|
+
Function,
|
|
19
|
+
Type,
|
|
20
|
+
Variable,
|
|
21
|
+
Property,
|
|
22
|
+
Tag,
|
|
23
|
+
Attribute,
|
|
24
|
+
Embedded,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
object CodeBlockHighlighter {
|
|
28
|
+
fun highlight(
|
|
29
|
+
target: Spannable,
|
|
30
|
+
code: String,
|
|
31
|
+
language: String?,
|
|
32
|
+
style: CodeBlockStyle,
|
|
33
|
+
offset: Int = 0,
|
|
34
|
+
) {
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
package com.renderrichtext.utils.common
|
|
2
|
-
|
|
3
|
-
import com.renderrichtext.parser.TiptapASTNode
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Shared code block node semantics, used by both tiptap flavors so the
|
|
7
|
-
* meaning of a CodeBlock AST node (its text, language, fence) is defined in
|
|
8
|
-
* one place. Language display names come from the shared C++ core
|
|
9
|
-
* (cpp/highlight/CodeBlockLanguages.hpp) so all platforms label fences
|
|
10
|
-
* identically; when the native library is unavailable the raw fence string
|
|
11
|
-
* is shown instead.
|
|
12
|
-
*/
|
|
13
|
-
object CodeBlockNode {
|
|
14
|
-
fun extractCode(node: TiptapASTNode): String {
|
|
15
|
-
val builder = StringBuilder()
|
|
16
|
-
|
|
17
|
-
fun append(current: TiptapASTNode) {
|
|
18
|
-
builder.append(current.content)
|
|
19
|
-
current.children.forEach { append(it) }
|
|
20
|
-
}
|
|
21
|
-
append(node)
|
|
22
|
-
return builder.toString().trimEnd('\n')
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
fun language(node: TiptapASTNode): String? = node.getAttribute("language")?.takeIf { it.isNotEmpty() }
|
|
26
|
-
|
|
27
|
-
fun fenceChar(node: TiptapASTNode): String = node.getAttribute("fenceChar")?.takeIf { it.isNotEmpty() } ?: "`"
|
|
28
|
-
|
|
29
|
-
fun fencedTiptap(
|
|
30
|
-
code: String,
|
|
31
|
-
language: String?,
|
|
32
|
-
fenceChar: String,
|
|
33
|
-
): String {
|
|
34
|
-
val fence = fenceChar.repeat(3)
|
|
35
|
-
return "$fence${language.orEmpty()}\n$code\n$fence"
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
fun displayLanguageName(language: String?): String {
|
|
39
|
-
if (language.isNullOrEmpty()) return ""
|
|
40
|
-
return language
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
package com.renderrichtext.utils.common
|
|
2
|
+
|
|
3
|
+
import com.renderrichtext.parser.TiptapASTNode
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Shared code block node semantics, used by both tiptap flavors so the
|
|
7
|
+
* meaning of a CodeBlock AST node (its text, language, fence) is defined in
|
|
8
|
+
* one place. Language display names come from the shared C++ core
|
|
9
|
+
* (cpp/highlight/CodeBlockLanguages.hpp) so all platforms label fences
|
|
10
|
+
* identically; when the native library is unavailable the raw fence string
|
|
11
|
+
* is shown instead.
|
|
12
|
+
*/
|
|
13
|
+
object CodeBlockNode {
|
|
14
|
+
fun extractCode(node: TiptapASTNode): String {
|
|
15
|
+
val builder = StringBuilder()
|
|
16
|
+
|
|
17
|
+
fun append(current: TiptapASTNode) {
|
|
18
|
+
builder.append(current.content)
|
|
19
|
+
current.children.forEach { append(it) }
|
|
20
|
+
}
|
|
21
|
+
append(node)
|
|
22
|
+
return builder.toString().trimEnd('\n')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun language(node: TiptapASTNode): String? = node.getAttribute("language")?.takeIf { it.isNotEmpty() }
|
|
26
|
+
|
|
27
|
+
fun fenceChar(node: TiptapASTNode): String = node.getAttribute("fenceChar")?.takeIf { it.isNotEmpty() } ?: "`"
|
|
28
|
+
|
|
29
|
+
fun fencedTiptap(
|
|
30
|
+
code: String,
|
|
31
|
+
language: String?,
|
|
32
|
+
fenceChar: String,
|
|
33
|
+
): String {
|
|
34
|
+
val fence = fenceChar.repeat(3)
|
|
35
|
+
return "$fence${language.orEmpty()}\n$code\n$fence"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fun displayLanguageName(language: String?): String {
|
|
39
|
+
if (language.isNullOrEmpty()) return ""
|
|
40
|
+
return language
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
package com.renderrichtext.utils.common
|
|
2
|
-
|
|
3
|
-
import android.text.TextUtils.TruncateAt
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Resolves an ellipsizeMode prop value (string) to the TruncateAt used by
|
|
7
|
-
* StaticLayout.Builder.setEllipsize() and TextView.setEllipsize().
|
|
8
|
-
*
|
|
9
|
-
* "clip" maps to null: with maxLines set, the layout still truncates but draws
|
|
10
|
-
* no ellipsis glyph. Mirrors React Native's TextAttributeProps.getEllipsizeMode.
|
|
11
|
-
*
|
|
12
|
-
* Stateless like [BreakStrategyUtils]: the mode is a per-view prop stored per
|
|
13
|
-
* viewId in [com.renderrichtext.MeasurementStore]. Measurement and
|
|
14
|
-
* render paths must resolve the same value, or the measured line count diverges
|
|
15
|
-
* from the rendered one and the view is sized incorrectly.
|
|
16
|
-
*/
|
|
17
|
-
object EllipsizeUtils {
|
|
18
|
-
const val DEFAULT_MODE = "tail"
|
|
19
|
-
|
|
20
|
-
fun resolveTruncateAt(mode: String?): TruncateAt? =
|
|
21
|
-
when (mode) {
|
|
22
|
-
"head" -> TruncateAt.START
|
|
23
|
-
"middle" -> TruncateAt.MIDDLE
|
|
24
|
-
"clip" -> null
|
|
25
|
-
else -> TruncateAt.END
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
package com.renderrichtext.utils.common
|
|
2
|
+
|
|
3
|
+
import android.text.TextUtils.TruncateAt
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolves an ellipsizeMode prop value (string) to the TruncateAt used by
|
|
7
|
+
* StaticLayout.Builder.setEllipsize() and TextView.setEllipsize().
|
|
8
|
+
*
|
|
9
|
+
* "clip" maps to null: with maxLines set, the layout still truncates but draws
|
|
10
|
+
* no ellipsis glyph. Mirrors React Native's TextAttributeProps.getEllipsizeMode.
|
|
11
|
+
*
|
|
12
|
+
* Stateless like [BreakStrategyUtils]: the mode is a per-view prop stored per
|
|
13
|
+
* viewId in [com.renderrichtext.MeasurementStore]. Measurement and
|
|
14
|
+
* render paths must resolve the same value, or the measured line count diverges
|
|
15
|
+
* from the rendered one and the view is sized incorrectly.
|
|
16
|
+
*/
|
|
17
|
+
object EllipsizeUtils {
|
|
18
|
+
const val DEFAULT_MODE = "tail"
|
|
19
|
+
|
|
20
|
+
fun resolveTruncateAt(mode: String?): TruncateAt? =
|
|
21
|
+
when (mode) {
|
|
22
|
+
"head" -> TruncateAt.START
|
|
23
|
+
"middle" -> TruncateAt.MIDDLE
|
|
24
|
+
"clip" -> null
|
|
25
|
+
else -> TruncateAt.END
|
|
26
|
+
}
|
|
27
|
+
}
|
package/android/src/main/java/com/renderrichtext/utils/common/EnrichedTiptapAncestorUtils.kt
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
package com.renderrichtext.utils.common
|
|
2
|
-
|
|
3
|
-
import android.view.View
|
|
4
|
-
import com.renderrichtext.EnrichedTiptapText
|
|
5
|
-
|
|
6
|
-
fun View.findEnrichedTiptapTextAncestor(): EnrichedTiptapText? {
|
|
7
|
-
var current: android.view.ViewParent? = parent
|
|
8
|
-
while (current != null && current !is EnrichedTiptapText) current = current.parent
|
|
9
|
-
return current as? EnrichedTiptapText
|
|
10
|
-
}
|
|
1
|
+
package com.renderrichtext.utils.common
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.renderrichtext.EnrichedTiptapText
|
|
5
|
+
|
|
6
|
+
fun View.findEnrichedTiptapTextAncestor(): EnrichedTiptapText? {
|
|
7
|
+
var current: android.view.ViewParent? = parent
|
|
8
|
+
while (current != null && current !is EnrichedTiptapText) current = current.parent
|
|
9
|
+
return current as? EnrichedTiptapText
|
|
10
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
package com.renderrichtext.utils.common
|
|
2
|
-
|
|
3
|
-
import com.renderrichtext.BuildConfig
|
|
4
|
-
|
|
5
|
-
object FeatureFlags {
|
|
6
|
-
const val IS_MATH_ENABLED: Boolean = BuildConfig.ENABLE_MATH
|
|
7
|
-
const val IS_VIDEO_ENABLED: Boolean = BuildConfig.ENABLE_VIDEO
|
|
8
|
-
const val IS_CODE_HIGHLIGHT_ENABLED: Boolean = BuildConfig.ENABLE_CODE_HIGHLIGHT
|
|
9
|
-
}
|
|
1
|
+
package com.renderrichtext.utils.common
|
|
2
|
+
|
|
3
|
+
import com.renderrichtext.BuildConfig
|
|
4
|
+
|
|
5
|
+
object FeatureFlags {
|
|
6
|
+
const val IS_MATH_ENABLED: Boolean = BuildConfig.ENABLE_MATH
|
|
7
|
+
const val IS_VIDEO_ENABLED: Boolean = BuildConfig.ENABLE_VIDEO
|
|
8
|
+
const val IS_CODE_HIGHLIGHT_ENABLED: Boolean = BuildConfig.ENABLE_CODE_HIGHLIGHT
|
|
9
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
package com.renderrichtext.utils.common
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReadableMap
|
|
4
|
-
|
|
5
|
-
data class LinkRecognition(
|
|
6
|
-
val text: LinkRegexConfig? = null,
|
|
7
|
-
val inlineCode: LinkRegexConfig? = null,
|
|
8
|
-
) {
|
|
9
|
-
companion object {
|
|
10
|
-
val NONE = LinkRecognition()
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
internal fun parseLinkRecognition(map: ReadableMap?): LinkRecognition {
|
|
15
|
-
if (map == null) return LinkRecognition.NONE
|
|
16
|
-
return LinkRecognition(
|
|
17
|
-
text = parseLinkRegexConfig(map.getMapOrNull("text")),
|
|
18
|
-
inlineCode = parseLinkRegexConfig(map.getMapOrNull("inlineCode")),
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
internal fun parseLinkRegexConfig(map: ReadableMap?): LinkRegexConfig? {
|
|
23
|
-
if (map == null) return null
|
|
24
|
-
return LinkRegexConfig(
|
|
25
|
-
pattern = if (map.hasKey("pattern")) map.getString("pattern") ?: "" else "",
|
|
26
|
-
caseInsensitive = map.hasKey("caseInsensitive") && map.getBoolean("caseInsensitive"),
|
|
27
|
-
dotAll = map.hasKey("dotAll") && map.getBoolean("dotAll"),
|
|
28
|
-
isDisabled = !map.hasKey("isDisabled") || map.getBoolean("isDisabled"),
|
|
29
|
-
isDefault = map.hasKey("isDefault") && map.getBoolean("isDefault"),
|
|
30
|
-
)
|
|
31
|
-
}
|
|
1
|
+
package com.renderrichtext.utils.common
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
|
|
5
|
+
data class LinkRecognition(
|
|
6
|
+
val text: LinkRegexConfig? = null,
|
|
7
|
+
val inlineCode: LinkRegexConfig? = null,
|
|
8
|
+
) {
|
|
9
|
+
companion object {
|
|
10
|
+
val NONE = LinkRecognition()
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
internal fun parseLinkRecognition(map: ReadableMap?): LinkRecognition {
|
|
15
|
+
if (map == null) return LinkRecognition.NONE
|
|
16
|
+
return LinkRecognition(
|
|
17
|
+
text = parseLinkRegexConfig(map.getMapOrNull("text")),
|
|
18
|
+
inlineCode = parseLinkRegexConfig(map.getMapOrNull("inlineCode")),
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
internal fun parseLinkRegexConfig(map: ReadableMap?): LinkRegexConfig? {
|
|
23
|
+
if (map == null) return null
|
|
24
|
+
return LinkRegexConfig(
|
|
25
|
+
pattern = if (map.hasKey("pattern")) map.getString("pattern") ?: "" else "",
|
|
26
|
+
caseInsensitive = map.hasKey("caseInsensitive") && map.getBoolean("caseInsensitive"),
|
|
27
|
+
dotAll = map.hasKey("dotAll") && map.getBoolean("dotAll"),
|
|
28
|
+
isDisabled = !map.hasKey("isDisabled") || map.getBoolean("isDisabled"),
|
|
29
|
+
isDefault = map.hasKey("isDefault") && map.getBoolean("isDefault"),
|
|
30
|
+
)
|
|
31
|
+
}
|