react-native-enriched-markdown 0.1.1 → 0.2.0
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/README.md +80 -8
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +17 -2
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +6 -1
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +9 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +6 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +28 -3
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +225 -1
- package/android/src/main/cpp/jni-adapter.cpp +28 -11
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +132 -15
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextLayoutManager.kt +1 -16
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +67 -13
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +241 -21
- package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/MarkdownAccessibilityHelper.kt +279 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/LinkLongPressEvent.kt +23 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/MarkdownASTNode.kt +2 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +17 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteRenderer.kt +13 -18
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeBlockRenderer.kt +23 -24
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeRenderer.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/DocumentRenderer.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/EmphasisRenderer.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HeadingRenderer.kt +18 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ImageRenderer.kt +22 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/LineBreakRenderer.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/LinkRenderer.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListItemRenderer.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListRenderer.kt +16 -9
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +5 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ParagraphRenderer.kt +23 -9
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/Renderer.kt +24 -10
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SpanStyleCache.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/StrikethroughRenderer.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/StrongRenderer.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/TextRenderer.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ThematicBreakRenderer.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/UnderlineRenderer.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ImageSpan.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LineHeightSpan.kt +8 -17
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt +19 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/MarginBottomSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/StrikethroughSpan.kt +12 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/BaseBlockStyle.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/BlockquoteStyle.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/CodeBlockStyle.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/HeadingStyle.kt +5 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ImageStyle.kt +3 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ListStyle.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/ParagraphStyle.kt +5 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StrikethroughStyle.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleConfig.kt +32 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleParser.kt +22 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/TextAlignment.kt +32 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/UnderlineStyle.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/HTMLGenerator.kt +23 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/LinkLongPressMovementMethod.kt +121 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/MarkdownExtractor.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/Utils.kt +58 -56
- package/android/src/main/jni/CMakeLists.txt +1 -13
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextShadowNode.cpp +0 -13
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextShadowNode.h +2 -14
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/conversions.h +3 -0
- package/cpp/parser/MD4CParser.cpp +21 -8
- package/cpp/parser/MD4CParser.hpp +5 -1
- package/cpp/parser/MarkdownASTNode.hpp +2 -0
- package/ios/EnrichedMarkdownText.mm +356 -29
- package/ios/attachments/{ImageAttachment.h → EnrichedMarkdownImageAttachment.h} +1 -1
- package/ios/attachments/{ImageAttachment.m → EnrichedMarkdownImageAttachment.m} +4 -4
- package/ios/generated/EnrichedMarkdownTextSpec/EventEmitters.cpp +9 -0
- package/ios/generated/EnrichedMarkdownTextSpec/EventEmitters.h +6 -0
- package/ios/generated/EnrichedMarkdownTextSpec/Props.cpp +28 -3
- package/ios/generated/EnrichedMarkdownTextSpec/Props.h +225 -1
- package/ios/parser/MarkdownASTNode.h +2 -0
- package/ios/parser/MarkdownParser.h +9 -0
- package/ios/parser/MarkdownParser.mm +31 -2
- package/ios/parser/MarkdownParserBridge.mm +13 -3
- package/ios/renderer/AttributedRenderer.h +2 -0
- package/ios/renderer/AttributedRenderer.m +52 -19
- package/ios/renderer/BlockquoteRenderer.m +7 -6
- package/ios/renderer/CodeBlockRenderer.m +9 -8
- package/ios/renderer/HeadingRenderer.m +31 -24
- package/ios/renderer/ImageRenderer.m +31 -10
- package/ios/renderer/ListItemRenderer.m +51 -39
- package/ios/renderer/ListRenderer.m +21 -18
- package/ios/renderer/ParagraphRenderer.m +27 -16
- package/ios/renderer/RenderContext.h +17 -0
- package/ios/renderer/RenderContext.m +66 -2
- package/ios/renderer/RendererFactory.m +6 -0
- package/ios/renderer/StrikethroughRenderer.h +6 -0
- package/ios/renderer/StrikethroughRenderer.m +40 -0
- package/ios/renderer/UnderlineRenderer.h +6 -0
- package/ios/renderer/UnderlineRenderer.m +39 -0
- package/ios/styles/StyleConfig.h +46 -0
- package/ios/styles/StyleConfig.mm +351 -12
- package/ios/utils/AccessibilityInfo.h +35 -0
- package/ios/utils/AccessibilityInfo.m +24 -0
- package/ios/utils/CodeBlockBackground.m +4 -9
- package/ios/utils/FontUtils.h +5 -0
- package/ios/utils/FontUtils.m +14 -0
- package/ios/utils/HTMLGenerator.m +21 -7
- package/ios/utils/MarkdownAccessibilityElementBuilder.h +45 -0
- package/ios/utils/MarkdownAccessibilityElementBuilder.m +323 -0
- package/ios/utils/MarkdownExtractor.m +18 -5
- package/ios/utils/ParagraphStyleUtils.h +10 -2
- package/ios/utils/ParagraphStyleUtils.m +57 -2
- package/ios/utils/PasteboardUtils.h +1 -1
- package/ios/utils/PasteboardUtils.m +3 -3
- package/lib/module/EnrichedMarkdownText.js +33 -2
- package/lib/module/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +83 -3
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.js +58 -14
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownText.d.ts +85 -3
- package/lib/typescript/src/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +75 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/EnrichedMarkdownText.tsx +133 -5
- package/src/EnrichedMarkdownTextNativeComponent.ts +83 -3
- package/src/index.tsx +5 -2
- package/src/normalizeMarkdownStyle.ts +46 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextState.cpp +0 -9
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/MarkdownTextState.h +0 -25
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { type NativeProps, type LinkPressEvent } from './EnrichedMarkdownTextNativeComponent';
|
|
1
|
+
import { type NativeProps, type LinkPressEvent, type LinkLongPressEvent } from './EnrichedMarkdownTextNativeComponent';
|
|
2
2
|
import type { ViewStyle, TextStyle } from 'react-native';
|
|
3
|
+
type TextAlign = 'auto' | 'left' | 'right' | 'center' | 'justify';
|
|
3
4
|
interface BaseBlockStyle {
|
|
4
5
|
fontSize?: number;
|
|
5
6
|
fontFamily?: string;
|
|
6
7
|
fontWeight?: string;
|
|
7
8
|
color?: string;
|
|
9
|
+
marginTop?: number;
|
|
8
10
|
marginBottom?: number;
|
|
9
11
|
lineHeight?: number;
|
|
10
12
|
}
|
|
11
13
|
interface ParagraphStyle extends BaseBlockStyle {
|
|
14
|
+
textAlign?: TextAlign;
|
|
12
15
|
}
|
|
13
16
|
interface HeadingStyle extends BaseBlockStyle {
|
|
17
|
+
textAlign?: TextAlign;
|
|
14
18
|
}
|
|
15
19
|
interface BlockquoteStyle extends BaseBlockStyle {
|
|
16
20
|
borderColor?: string;
|
|
@@ -43,6 +47,20 @@ interface StrongStyle {
|
|
|
43
47
|
interface EmphasisStyle {
|
|
44
48
|
color?: string;
|
|
45
49
|
}
|
|
50
|
+
interface StrikethroughStyle {
|
|
51
|
+
/**
|
|
52
|
+
* Color of the strikethrough line.
|
|
53
|
+
* @platform iOS
|
|
54
|
+
*/
|
|
55
|
+
color?: string;
|
|
56
|
+
}
|
|
57
|
+
interface UnderlineStyle {
|
|
58
|
+
/**
|
|
59
|
+
* Color of the underline.
|
|
60
|
+
* @platform iOS
|
|
61
|
+
*/
|
|
62
|
+
color?: string;
|
|
63
|
+
}
|
|
46
64
|
interface CodeStyle {
|
|
47
65
|
color?: string;
|
|
48
66
|
backgroundColor?: string;
|
|
@@ -51,6 +69,7 @@ interface CodeStyle {
|
|
|
51
69
|
interface ImageStyle {
|
|
52
70
|
height?: number;
|
|
53
71
|
borderRadius?: number;
|
|
72
|
+
marginTop?: number;
|
|
54
73
|
marginBottom?: number;
|
|
55
74
|
}
|
|
56
75
|
interface InlineImageStyle {
|
|
@@ -76,12 +95,27 @@ export interface MarkdownStyle {
|
|
|
76
95
|
link?: LinkStyle;
|
|
77
96
|
strong?: StrongStyle;
|
|
78
97
|
em?: EmphasisStyle;
|
|
98
|
+
strikethrough?: StrikethroughStyle;
|
|
99
|
+
underline?: UnderlineStyle;
|
|
79
100
|
code?: CodeStyle;
|
|
80
101
|
image?: ImageStyle;
|
|
81
102
|
inlineImage?: InlineImageStyle;
|
|
82
103
|
thematicBreak?: ThematicBreakStyle;
|
|
83
104
|
}
|
|
84
|
-
|
|
105
|
+
/**
|
|
106
|
+
* MD4C parser flags configuration.
|
|
107
|
+
* Controls how the markdown parser interprets certain syntax.
|
|
108
|
+
*/
|
|
109
|
+
export interface Md4cFlags {
|
|
110
|
+
/**
|
|
111
|
+
* Enable underline syntax support (__text__).
|
|
112
|
+
* When enabled, underscores are treated as underline markers.
|
|
113
|
+
* When disabled, underscores are treated as emphasis markers (same as asterisks).
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
116
|
+
underline?: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface EnrichedMarkdownTextProps extends Omit<NativeProps, 'markdownStyle' | 'style' | 'onLinkPress' | 'onLinkLongPress' | 'md4cFlags' | 'enableLinkPreview'> {
|
|
85
119
|
/**
|
|
86
120
|
* Style configuration for markdown elements
|
|
87
121
|
*/
|
|
@@ -95,7 +129,55 @@ export interface EnrichedMarkdownTextProps extends Omit<NativeProps, 'markdownSt
|
|
|
95
129
|
* Receives the link URL directly.
|
|
96
130
|
*/
|
|
97
131
|
onLinkPress?: (event: LinkPressEvent) => void;
|
|
132
|
+
/**
|
|
133
|
+
* Callback fired when a link is long pressed.
|
|
134
|
+
* Receives the link URL directly.
|
|
135
|
+
* - iOS: When provided, automatically disables the system link preview (unless `enableLinkPreview` is explicitly set to `true`).
|
|
136
|
+
* - Android: Handles long press gestures on links.
|
|
137
|
+
*/
|
|
138
|
+
onLinkLongPress?: (event: LinkLongPressEvent) => void;
|
|
139
|
+
/**
|
|
140
|
+
* Controls whether the system link preview is shown on long press (iOS only).
|
|
141
|
+
*
|
|
142
|
+
* When `true`, long-pressing a link shows the native iOS link preview.
|
|
143
|
+
* When `false`, the system preview is suppressed.
|
|
144
|
+
*
|
|
145
|
+
* Defaults to `true`, but automatically becomes `false` when `onLinkLongPress` is provided.
|
|
146
|
+
* Set explicitly to override the automatic behavior.
|
|
147
|
+
*
|
|
148
|
+
* Android: No-op.
|
|
149
|
+
*
|
|
150
|
+
* @default true
|
|
151
|
+
* @platform ios
|
|
152
|
+
*/
|
|
153
|
+
enableLinkPreview?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* MD4C parser flags configuration.
|
|
156
|
+
* Controls how the markdown parser interprets certain syntax.
|
|
157
|
+
*/
|
|
158
|
+
md4cFlags?: Md4cFlags;
|
|
159
|
+
/**
|
|
160
|
+
* Specifies whether fonts should scale to respect Text Size accessibility settings.
|
|
161
|
+
* When false, text will not scale with the user's accessibility settings.
|
|
162
|
+
* @default true
|
|
163
|
+
*/
|
|
164
|
+
allowFontScaling?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Specifies the largest possible scale a font can reach when allowFontScaling is enabled.
|
|
167
|
+
* Possible values:
|
|
168
|
+
* - undefined/null (default): no limit
|
|
169
|
+
* - 0: no limit
|
|
170
|
+
* - >= 1: sets the maxFontSizeMultiplier of this node to this value
|
|
171
|
+
* @default undefined
|
|
172
|
+
*/
|
|
173
|
+
maxFontSizeMultiplier?: number;
|
|
174
|
+
/**
|
|
175
|
+
* When false (default), removes trailing margin from the last element to eliminate bottom spacing.
|
|
176
|
+
* When true, keeps the trailing margin from the last element's marginBottom style.
|
|
177
|
+
* @default false
|
|
178
|
+
*/
|
|
179
|
+
allowTrailingMargin?: boolean;
|
|
98
180
|
}
|
|
99
|
-
export declare const EnrichedMarkdownText: ({ markdown, markdownStyle, containerStyle, onLinkPress,
|
|
181
|
+
export declare const EnrichedMarkdownText: ({ markdown, markdownStyle, containerStyle, onLinkPress, onLinkLongPress, enableLinkPreview, selectable, md4cFlags, allowFontScaling, maxFontSizeMultiplier, allowTrailingMargin, ...rest }: EnrichedMarkdownTextProps) => import("react/jsx-runtime").JSX.Element;
|
|
100
182
|
export default EnrichedMarkdownText;
|
|
101
183
|
//# sourceMappingURL=EnrichedMarkdownText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnrichedMarkdownText.d.ts","sourceRoot":"","sources":["../../../src/EnrichedMarkdownText.tsx"],"names":[],"mappings":"AACA,OAA4C,EAC1C,KAAK,WAAW,EAChB,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"EnrichedMarkdownText.d.ts","sourceRoot":"","sources":["../../../src/EnrichedMarkdownText.tsx"],"names":[],"mappings":"AACA,OAA4C,EAC1C,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAwB,MAAM,cAAc,CAAC;AAE/E,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAElE,UAAU,cAAc;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,cAAe,SAAQ,cAAc;IAC7C,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,UAAU,YAAa,SAAQ,cAAc;IAC3C,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,UAAU,eAAgB,SAAQ,cAAc;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,UAAU,SAAU,SAAQ,cAAc;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,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OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAMD,eAAO,MAAM,oBAAoB,GAAI,4LAalC,yBAAyB,4CA6C3B,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -4,12 +4,15 @@ interface BaseBlockStyleInternal {
|
|
|
4
4
|
fontFamily: string;
|
|
5
5
|
fontWeight: string;
|
|
6
6
|
color: ColorValue;
|
|
7
|
+
marginTop: CodegenTypes.Float;
|
|
7
8
|
marginBottom: CodegenTypes.Float;
|
|
8
9
|
lineHeight: CodegenTypes.Float;
|
|
9
10
|
}
|
|
10
11
|
interface ParagraphStyleInternal extends BaseBlockStyleInternal {
|
|
12
|
+
textAlign: string;
|
|
11
13
|
}
|
|
12
14
|
interface HeadingStyleInternal extends BaseBlockStyleInternal {
|
|
15
|
+
textAlign: string;
|
|
13
16
|
}
|
|
14
17
|
interface BlockquoteStyleInternal extends BaseBlockStyleInternal {
|
|
15
18
|
borderColor: ColorValue;
|
|
@@ -42,6 +45,12 @@ interface StrongStyleInternal {
|
|
|
42
45
|
interface EmphasisStyleInternal {
|
|
43
46
|
color?: ColorValue;
|
|
44
47
|
}
|
|
48
|
+
interface StrikethroughStyleInternal {
|
|
49
|
+
color: ColorValue;
|
|
50
|
+
}
|
|
51
|
+
interface UnderlineStyleInternal {
|
|
52
|
+
color: ColorValue;
|
|
53
|
+
}
|
|
45
54
|
interface CodeStyleInternal {
|
|
46
55
|
color: ColorValue;
|
|
47
56
|
backgroundColor: ColorValue;
|
|
@@ -50,6 +59,7 @@ interface CodeStyleInternal {
|
|
|
50
59
|
interface ImageStyleInternal {
|
|
51
60
|
height: CodegenTypes.Float;
|
|
52
61
|
borderRadius: CodegenTypes.Float;
|
|
62
|
+
marginTop: CodegenTypes.Float;
|
|
53
63
|
marginBottom: CodegenTypes.Float;
|
|
54
64
|
}
|
|
55
65
|
interface InlineImageStyleInternal {
|
|
@@ -75,6 +85,8 @@ export interface MarkdownStyleInternal {
|
|
|
75
85
|
link: LinkStyleInternal;
|
|
76
86
|
strong: StrongStyleInternal;
|
|
77
87
|
em: EmphasisStyleInternal;
|
|
88
|
+
strikethrough: StrikethroughStyleInternal;
|
|
89
|
+
underline: UnderlineStyleInternal;
|
|
78
90
|
code: CodeStyleInternal;
|
|
79
91
|
image: ImageStyleInternal;
|
|
80
92
|
inlineImage: InlineImageStyleInternal;
|
|
@@ -83,6 +95,22 @@ export interface MarkdownStyleInternal {
|
|
|
83
95
|
export interface LinkPressEvent {
|
|
84
96
|
url: string;
|
|
85
97
|
}
|
|
98
|
+
export interface LinkLongPressEvent {
|
|
99
|
+
url: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* MD4C parser flags configuration.
|
|
103
|
+
* Controls how the markdown parser interprets certain syntax.
|
|
104
|
+
*/
|
|
105
|
+
export interface Md4cFlagsInternal {
|
|
106
|
+
/**
|
|
107
|
+
* Enable underline syntax support (__text__).
|
|
108
|
+
* When enabled, underscores are treated as underline markers.
|
|
109
|
+
* When disabled, underscores are treated as emphasis markers (same as asterisks).
|
|
110
|
+
* @default false
|
|
111
|
+
*/
|
|
112
|
+
underline: boolean;
|
|
113
|
+
}
|
|
86
114
|
export interface NativeProps extends ViewProps {
|
|
87
115
|
/**
|
|
88
116
|
* Markdown content to render.
|
|
@@ -99,12 +127,58 @@ export interface NativeProps extends ViewProps {
|
|
|
99
127
|
* Receives the URL that was tapped.
|
|
100
128
|
*/
|
|
101
129
|
onLinkPress?: CodegenTypes.BubblingEventHandler<LinkPressEvent>;
|
|
130
|
+
/**
|
|
131
|
+
* Callback fired when a link is long pressed.
|
|
132
|
+
* Receives the URL that was long pressed.
|
|
133
|
+
* - iOS: When provided, overrides the system link preview behavior.
|
|
134
|
+
* - Android: Handles long press gestures on links.
|
|
135
|
+
*/
|
|
136
|
+
onLinkLongPress?: CodegenTypes.BubblingEventHandler<LinkLongPressEvent>;
|
|
137
|
+
/**
|
|
138
|
+
* Controls whether the system link preview is shown on long press (iOS only).
|
|
139
|
+
*
|
|
140
|
+
* When `true` (default), long-pressing a link shows the native iOS link preview.
|
|
141
|
+
* When `false`, the system preview is suppressed.
|
|
142
|
+
*
|
|
143
|
+
* Automatically set to `false` when `onLinkLongPress` is provided (unless explicitly overridden).
|
|
144
|
+
*
|
|
145
|
+
* Android: No-op (Android doesn't have a system link preview).
|
|
146
|
+
*
|
|
147
|
+
* @default true
|
|
148
|
+
*/
|
|
149
|
+
enableLinkPreview?: CodegenTypes.WithDefault<boolean, true>;
|
|
102
150
|
/**
|
|
103
151
|
* - iOS: Controls text selection and link previews on long press.
|
|
104
152
|
* - Android: Controls text selection.
|
|
105
153
|
* @default true
|
|
106
154
|
*/
|
|
107
|
-
|
|
155
|
+
selectable?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* MD4C parser flags configuration.
|
|
158
|
+
* Controls how the markdown parser interprets certain syntax.
|
|
159
|
+
*/
|
|
160
|
+
md4cFlags: Md4cFlagsInternal;
|
|
161
|
+
/**
|
|
162
|
+
* Specifies whether fonts should scale to respect Text Size accessibility settings.
|
|
163
|
+
* When false, text will not scale with the user's accessibility settings.
|
|
164
|
+
* @default true
|
|
165
|
+
*/
|
|
166
|
+
allowFontScaling?: CodegenTypes.WithDefault<boolean, true>;
|
|
167
|
+
/**
|
|
168
|
+
* Specifies the largest possible scale a font can reach when allowFontScaling is enabled.
|
|
169
|
+
* Possible values:
|
|
170
|
+
* - undefined/null (default): inherit from parent or global default (no limit)
|
|
171
|
+
* - 0: no limit, ignore parent/global default
|
|
172
|
+
* - >= 1: sets the maxFontSizeMultiplier of this node to this value
|
|
173
|
+
* @default undefined
|
|
174
|
+
*/
|
|
175
|
+
maxFontSizeMultiplier?: CodegenTypes.Float;
|
|
176
|
+
/**
|
|
177
|
+
* When false (default), removes trailing margin from the last element to eliminate bottom spacing.
|
|
178
|
+
* When true, keeps the trailing margin from the last element's marginBottom style.
|
|
179
|
+
* @default false
|
|
180
|
+
*/
|
|
181
|
+
allowTrailingMargin?: CodegenTypes.WithDefault<boolean, false>;
|
|
108
182
|
}
|
|
109
183
|
declare const _default: import("react-native/types_generated/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
110
184
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnrichedMarkdownTextNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/EnrichedMarkdownTextNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAGtB,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC;IACjC,UAAU,EAAE,YAAY,CAAC,KAAK,CAAC;CAChC;AAED,UAAU,sBAAuB,SAAQ,sBAAsB;
|
|
1
|
+
{"version":3,"file":"EnrichedMarkdownTextNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/EnrichedMarkdownTextNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAGtB,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC;IAC9B,YAAY,EA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,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,aAAa,EAAE,qBAAqB,CAAC;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAChE;;;;;OAKG;IACH,eAAe,CAAC,EAAE,YAAY,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;IACxE;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC5D;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,SAAS,EAAE,iBAAiB,CAAC;IAC7B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3D;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC;IAC3C;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;CAChE;;AAED,wBAA2E"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { default as EnrichedMarkdownText } from './EnrichedMarkdownText';
|
|
2
|
-
export {
|
|
3
|
-
export type {
|
|
4
|
-
export type { LinkPressEvent } from './EnrichedMarkdownTextNativeComponent';
|
|
2
|
+
export type { EnrichedMarkdownTextProps, MarkdownStyle, Md4cFlags, } from './EnrichedMarkdownText';
|
|
3
|
+
export type { LinkPressEvent, LinkLongPressEvent, } from './EnrichedMarkdownTextNativeComponent';
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,YAAY,EACV,yBAAyB,EACzB,aAAa,EACb,SAAS,GACV,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,cAAc,EACd,kBAAkB,GACnB,MAAM,uCAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeMarkdownStyle.d.ts","sourceRoot":"","sources":["../../../src/normalizeMarkdownStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAEnF,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,GAAG,SAAS,KACxB,UAAU,GAAG,SAMf,CAAC;
|
|
1
|
+
{"version":3,"file":"normalizeMarkdownStyle.d.ts","sourceRoot":"","sources":["../../../src/normalizeMarkdownStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAEnF,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,GAAG,SAAS,KACxB,UAAU,GAAG,SAMf,CAAC;AAsMF,eAAO,MAAM,sBAAsB,GACjC,OAAO,aAAa,KACnB,qBAkNF,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,22 +2,30 @@ import { useMemo, useCallback } from 'react';
|
|
|
2
2
|
import EnrichedMarkdownTextNativeComponent, {
|
|
3
3
|
type NativeProps,
|
|
4
4
|
type LinkPressEvent,
|
|
5
|
+
type LinkLongPressEvent,
|
|
5
6
|
} from './EnrichedMarkdownTextNativeComponent';
|
|
6
7
|
import { normalizeMarkdownStyle } from './normalizeMarkdownStyle';
|
|
7
8
|
import type { ViewStyle, TextStyle, NativeSyntheticEvent } from 'react-native';
|
|
8
9
|
|
|
10
|
+
type TextAlign = 'auto' | 'left' | 'right' | 'center' | 'justify';
|
|
11
|
+
|
|
9
12
|
interface BaseBlockStyle {
|
|
10
13
|
fontSize?: number;
|
|
11
14
|
fontFamily?: string;
|
|
12
15
|
fontWeight?: string;
|
|
13
16
|
color?: string;
|
|
17
|
+
marginTop?: number;
|
|
14
18
|
marginBottom?: number;
|
|
15
19
|
lineHeight?: number;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
|
-
interface ParagraphStyle extends BaseBlockStyle {
|
|
22
|
+
interface ParagraphStyle extends BaseBlockStyle {
|
|
23
|
+
textAlign?: TextAlign;
|
|
24
|
+
}
|
|
19
25
|
|
|
20
|
-
interface HeadingStyle extends BaseBlockStyle {
|
|
26
|
+
interface HeadingStyle extends BaseBlockStyle {
|
|
27
|
+
textAlign?: TextAlign;
|
|
28
|
+
}
|
|
21
29
|
|
|
22
30
|
interface BlockquoteStyle extends BaseBlockStyle {
|
|
23
31
|
borderColor?: string;
|
|
@@ -56,6 +64,22 @@ interface EmphasisStyle {
|
|
|
56
64
|
color?: string;
|
|
57
65
|
}
|
|
58
66
|
|
|
67
|
+
interface StrikethroughStyle {
|
|
68
|
+
/**
|
|
69
|
+
* Color of the strikethrough line.
|
|
70
|
+
* @platform iOS
|
|
71
|
+
*/
|
|
72
|
+
color?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface UnderlineStyle {
|
|
76
|
+
/**
|
|
77
|
+
* Color of the underline.
|
|
78
|
+
* @platform iOS
|
|
79
|
+
*/
|
|
80
|
+
color?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
59
83
|
interface CodeStyle {
|
|
60
84
|
color?: string;
|
|
61
85
|
backgroundColor?: string;
|
|
@@ -65,6 +89,7 @@ interface CodeStyle {
|
|
|
65
89
|
interface ImageStyle {
|
|
66
90
|
height?: number;
|
|
67
91
|
borderRadius?: number;
|
|
92
|
+
marginTop?: number;
|
|
68
93
|
marginBottom?: number;
|
|
69
94
|
}
|
|
70
95
|
|
|
@@ -93,14 +118,38 @@ export interface MarkdownStyle {
|
|
|
93
118
|
link?: LinkStyle;
|
|
94
119
|
strong?: StrongStyle;
|
|
95
120
|
em?: EmphasisStyle;
|
|
121
|
+
strikethrough?: StrikethroughStyle;
|
|
122
|
+
underline?: UnderlineStyle;
|
|
96
123
|
code?: CodeStyle;
|
|
97
124
|
image?: ImageStyle;
|
|
98
125
|
inlineImage?: InlineImageStyle;
|
|
99
126
|
thematicBreak?: ThematicBreakStyle;
|
|
100
127
|
}
|
|
101
128
|
|
|
129
|
+
/**
|
|
130
|
+
* MD4C parser flags configuration.
|
|
131
|
+
* Controls how the markdown parser interprets certain syntax.
|
|
132
|
+
*/
|
|
133
|
+
export interface Md4cFlags {
|
|
134
|
+
/**
|
|
135
|
+
* Enable underline syntax support (__text__).
|
|
136
|
+
* When enabled, underscores are treated as underline markers.
|
|
137
|
+
* When disabled, underscores are treated as emphasis markers (same as asterisks).
|
|
138
|
+
* @default false
|
|
139
|
+
*/
|
|
140
|
+
underline?: boolean;
|
|
141
|
+
}
|
|
142
|
+
|
|
102
143
|
export interface EnrichedMarkdownTextProps
|
|
103
|
-
extends Omit<
|
|
144
|
+
extends Omit<
|
|
145
|
+
NativeProps,
|
|
146
|
+
| 'markdownStyle'
|
|
147
|
+
| 'style'
|
|
148
|
+
| 'onLinkPress'
|
|
149
|
+
| 'onLinkLongPress'
|
|
150
|
+
| 'md4cFlags'
|
|
151
|
+
| 'enableLinkPreview'
|
|
152
|
+
> {
|
|
104
153
|
/**
|
|
105
154
|
* Style configuration for markdown elements
|
|
106
155
|
*/
|
|
@@ -114,14 +163,72 @@ export interface EnrichedMarkdownTextProps
|
|
|
114
163
|
* Receives the link URL directly.
|
|
115
164
|
*/
|
|
116
165
|
onLinkPress?: (event: LinkPressEvent) => void;
|
|
166
|
+
/**
|
|
167
|
+
* Callback fired when a link is long pressed.
|
|
168
|
+
* Receives the link URL directly.
|
|
169
|
+
* - iOS: When provided, automatically disables the system link preview (unless `enableLinkPreview` is explicitly set to `true`).
|
|
170
|
+
* - Android: Handles long press gestures on links.
|
|
171
|
+
*/
|
|
172
|
+
onLinkLongPress?: (event: LinkLongPressEvent) => void;
|
|
173
|
+
/**
|
|
174
|
+
* Controls whether the system link preview is shown on long press (iOS only).
|
|
175
|
+
*
|
|
176
|
+
* When `true`, long-pressing a link shows the native iOS link preview.
|
|
177
|
+
* When `false`, the system preview is suppressed.
|
|
178
|
+
*
|
|
179
|
+
* Defaults to `true`, but automatically becomes `false` when `onLinkLongPress` is provided.
|
|
180
|
+
* Set explicitly to override the automatic behavior.
|
|
181
|
+
*
|
|
182
|
+
* Android: No-op.
|
|
183
|
+
*
|
|
184
|
+
* @default true
|
|
185
|
+
* @platform ios
|
|
186
|
+
*/
|
|
187
|
+
enableLinkPreview?: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* MD4C parser flags configuration.
|
|
190
|
+
* Controls how the markdown parser interprets certain syntax.
|
|
191
|
+
*/
|
|
192
|
+
md4cFlags?: Md4cFlags;
|
|
193
|
+
/**
|
|
194
|
+
* Specifies whether fonts should scale to respect Text Size accessibility settings.
|
|
195
|
+
* When false, text will not scale with the user's accessibility settings.
|
|
196
|
+
* @default true
|
|
197
|
+
*/
|
|
198
|
+
allowFontScaling?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Specifies the largest possible scale a font can reach when allowFontScaling is enabled.
|
|
201
|
+
* Possible values:
|
|
202
|
+
* - undefined/null (default): no limit
|
|
203
|
+
* - 0: no limit
|
|
204
|
+
* - >= 1: sets the maxFontSizeMultiplier of this node to this value
|
|
205
|
+
* @default undefined
|
|
206
|
+
*/
|
|
207
|
+
maxFontSizeMultiplier?: number;
|
|
208
|
+
/**
|
|
209
|
+
* When false (default), removes trailing margin from the last element to eliminate bottom spacing.
|
|
210
|
+
* When true, keeps the trailing margin from the last element's marginBottom style.
|
|
211
|
+
* @default false
|
|
212
|
+
*/
|
|
213
|
+
allowTrailingMargin?: boolean;
|
|
117
214
|
}
|
|
118
215
|
|
|
216
|
+
const defaultMd4cFlags: Md4cFlags = {
|
|
217
|
+
underline: false,
|
|
218
|
+
};
|
|
219
|
+
|
|
119
220
|
export const EnrichedMarkdownText = ({
|
|
120
221
|
markdown,
|
|
121
222
|
markdownStyle = {},
|
|
122
223
|
containerStyle,
|
|
123
224
|
onLinkPress,
|
|
124
|
-
|
|
225
|
+
onLinkLongPress,
|
|
226
|
+
enableLinkPreview,
|
|
227
|
+
selectable = true,
|
|
228
|
+
md4cFlags = defaultMd4cFlags,
|
|
229
|
+
allowFontScaling = true,
|
|
230
|
+
maxFontSizeMultiplier,
|
|
231
|
+
allowTrailingMargin = false,
|
|
125
232
|
...rest
|
|
126
233
|
}: EnrichedMarkdownTextProps) => {
|
|
127
234
|
const normalizedStyle = useMemo(
|
|
@@ -129,6 +236,13 @@ export const EnrichedMarkdownText = ({
|
|
|
129
236
|
[markdownStyle]
|
|
130
237
|
);
|
|
131
238
|
|
|
239
|
+
const normalizedMd4cFlags = useMemo(
|
|
240
|
+
() => ({
|
|
241
|
+
underline: md4cFlags.underline ?? false,
|
|
242
|
+
}),
|
|
243
|
+
[md4cFlags]
|
|
244
|
+
);
|
|
245
|
+
|
|
132
246
|
const handleLinkPress = useCallback(
|
|
133
247
|
(e: NativeSyntheticEvent<LinkPressEvent>) => {
|
|
134
248
|
const { url } = e.nativeEvent;
|
|
@@ -137,12 +251,26 @@ export const EnrichedMarkdownText = ({
|
|
|
137
251
|
[onLinkPress]
|
|
138
252
|
);
|
|
139
253
|
|
|
254
|
+
const handleLinkLongPress = useCallback(
|
|
255
|
+
(e: NativeSyntheticEvent<LinkLongPressEvent>) => {
|
|
256
|
+
const { url } = e.nativeEvent;
|
|
257
|
+
onLinkLongPress?.({ url });
|
|
258
|
+
},
|
|
259
|
+
[onLinkLongPress]
|
|
260
|
+
);
|
|
261
|
+
|
|
140
262
|
return (
|
|
141
263
|
<EnrichedMarkdownTextNativeComponent
|
|
142
264
|
markdown={markdown}
|
|
143
265
|
markdownStyle={normalizedStyle}
|
|
144
266
|
onLinkPress={handleLinkPress}
|
|
145
|
-
|
|
267
|
+
onLinkLongPress={handleLinkLongPress}
|
|
268
|
+
enableLinkPreview={onLinkLongPress == null && (enableLinkPreview ?? true)}
|
|
269
|
+
selectable={selectable}
|
|
270
|
+
md4cFlags={normalizedMd4cFlags}
|
|
271
|
+
allowFontScaling={allowFontScaling}
|
|
272
|
+
maxFontSizeMultiplier={maxFontSizeMultiplier}
|
|
273
|
+
allowTrailingMargin={allowTrailingMargin}
|
|
146
274
|
style={containerStyle}
|
|
147
275
|
{...rest}
|
|
148
276
|
/>
|
|
@@ -11,13 +11,18 @@ interface BaseBlockStyleInternal {
|
|
|
11
11
|
fontFamily: string;
|
|
12
12
|
fontWeight: string;
|
|
13
13
|
color: ColorValue;
|
|
14
|
+
marginTop: CodegenTypes.Float;
|
|
14
15
|
marginBottom: CodegenTypes.Float;
|
|
15
16
|
lineHeight: CodegenTypes.Float;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
interface ParagraphStyleInternal extends BaseBlockStyleInternal {
|
|
19
|
+
interface ParagraphStyleInternal extends BaseBlockStyleInternal {
|
|
20
|
+
textAlign: string;
|
|
21
|
+
}
|
|
19
22
|
|
|
20
|
-
interface HeadingStyleInternal extends BaseBlockStyleInternal {
|
|
23
|
+
interface HeadingStyleInternal extends BaseBlockStyleInternal {
|
|
24
|
+
textAlign: string;
|
|
25
|
+
}
|
|
21
26
|
|
|
22
27
|
interface BlockquoteStyleInternal extends BaseBlockStyleInternal {
|
|
23
28
|
borderColor: ColorValue;
|
|
@@ -56,6 +61,14 @@ interface EmphasisStyleInternal {
|
|
|
56
61
|
color?: ColorValue;
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
interface StrikethroughStyleInternal {
|
|
65
|
+
color: ColorValue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface UnderlineStyleInternal {
|
|
69
|
+
color: ColorValue;
|
|
70
|
+
}
|
|
71
|
+
|
|
59
72
|
interface CodeStyleInternal {
|
|
60
73
|
color: ColorValue;
|
|
61
74
|
backgroundColor: ColorValue;
|
|
@@ -65,6 +78,7 @@ interface CodeStyleInternal {
|
|
|
65
78
|
interface ImageStyleInternal {
|
|
66
79
|
height: CodegenTypes.Float;
|
|
67
80
|
borderRadius: CodegenTypes.Float;
|
|
81
|
+
marginTop: CodegenTypes.Float;
|
|
68
82
|
marginBottom: CodegenTypes.Float;
|
|
69
83
|
}
|
|
70
84
|
|
|
@@ -93,6 +107,8 @@ export interface MarkdownStyleInternal {
|
|
|
93
107
|
link: LinkStyleInternal;
|
|
94
108
|
strong: StrongStyleInternal;
|
|
95
109
|
em: EmphasisStyleInternal;
|
|
110
|
+
strikethrough: StrikethroughStyleInternal;
|
|
111
|
+
underline: UnderlineStyleInternal;
|
|
96
112
|
code: CodeStyleInternal;
|
|
97
113
|
image: ImageStyleInternal;
|
|
98
114
|
inlineImage: InlineImageStyleInternal;
|
|
@@ -103,6 +119,24 @@ export interface LinkPressEvent {
|
|
|
103
119
|
url: string;
|
|
104
120
|
}
|
|
105
121
|
|
|
122
|
+
export interface LinkLongPressEvent {
|
|
123
|
+
url: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* MD4C parser flags configuration.
|
|
128
|
+
* Controls how the markdown parser interprets certain syntax.
|
|
129
|
+
*/
|
|
130
|
+
export interface Md4cFlagsInternal {
|
|
131
|
+
/**
|
|
132
|
+
* Enable underline syntax support (__text__).
|
|
133
|
+
* When enabled, underscores are treated as underline markers.
|
|
134
|
+
* When disabled, underscores are treated as emphasis markers (same as asterisks).
|
|
135
|
+
* @default false
|
|
136
|
+
*/
|
|
137
|
+
underline: boolean;
|
|
138
|
+
}
|
|
139
|
+
|
|
106
140
|
export interface NativeProps extends ViewProps {
|
|
107
141
|
/**
|
|
108
142
|
* Markdown content to render.
|
|
@@ -119,12 +153,58 @@ export interface NativeProps extends ViewProps {
|
|
|
119
153
|
* Receives the URL that was tapped.
|
|
120
154
|
*/
|
|
121
155
|
onLinkPress?: CodegenTypes.BubblingEventHandler<LinkPressEvent>;
|
|
156
|
+
/**
|
|
157
|
+
* Callback fired when a link is long pressed.
|
|
158
|
+
* Receives the URL that was long pressed.
|
|
159
|
+
* - iOS: When provided, overrides the system link preview behavior.
|
|
160
|
+
* - Android: Handles long press gestures on links.
|
|
161
|
+
*/
|
|
162
|
+
onLinkLongPress?: CodegenTypes.BubblingEventHandler<LinkLongPressEvent>;
|
|
163
|
+
/**
|
|
164
|
+
* Controls whether the system link preview is shown on long press (iOS only).
|
|
165
|
+
*
|
|
166
|
+
* When `true` (default), long-pressing a link shows the native iOS link preview.
|
|
167
|
+
* When `false`, the system preview is suppressed.
|
|
168
|
+
*
|
|
169
|
+
* Automatically set to `false` when `onLinkLongPress` is provided (unless explicitly overridden).
|
|
170
|
+
*
|
|
171
|
+
* Android: No-op (Android doesn't have a system link preview).
|
|
172
|
+
*
|
|
173
|
+
* @default true
|
|
174
|
+
*/
|
|
175
|
+
enableLinkPreview?: CodegenTypes.WithDefault<boolean, true>;
|
|
122
176
|
/**
|
|
123
177
|
* - iOS: Controls text selection and link previews on long press.
|
|
124
178
|
* - Android: Controls text selection.
|
|
125
179
|
* @default true
|
|
126
180
|
*/
|
|
127
|
-
|
|
181
|
+
selectable?: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* MD4C parser flags configuration.
|
|
184
|
+
* Controls how the markdown parser interprets certain syntax.
|
|
185
|
+
*/
|
|
186
|
+
md4cFlags: Md4cFlagsInternal;
|
|
187
|
+
/**
|
|
188
|
+
* Specifies whether fonts should scale to respect Text Size accessibility settings.
|
|
189
|
+
* When false, text will not scale with the user's accessibility settings.
|
|
190
|
+
* @default true
|
|
191
|
+
*/
|
|
192
|
+
allowFontScaling?: CodegenTypes.WithDefault<boolean, true>;
|
|
193
|
+
/**
|
|
194
|
+
* Specifies the largest possible scale a font can reach when allowFontScaling is enabled.
|
|
195
|
+
* Possible values:
|
|
196
|
+
* - undefined/null (default): inherit from parent or global default (no limit)
|
|
197
|
+
* - 0: no limit, ignore parent/global default
|
|
198
|
+
* - >= 1: sets the maxFontSizeMultiplier of this node to this value
|
|
199
|
+
* @default undefined
|
|
200
|
+
*/
|
|
201
|
+
maxFontSizeMultiplier?: CodegenTypes.Float;
|
|
202
|
+
/**
|
|
203
|
+
* When false (default), removes trailing margin from the last element to eliminate bottom spacing.
|
|
204
|
+
* When true, keeps the trailing margin from the last element's marginBottom style.
|
|
205
|
+
* @default false
|
|
206
|
+
*/
|
|
207
|
+
allowTrailingMargin?: CodegenTypes.WithDefault<boolean, false>;
|
|
128
208
|
}
|
|
129
209
|
|
|
130
210
|
export default codegenNativeComponent<NativeProps>('EnrichedMarkdownText');
|