react-native-enriched-markdown-scaffold 1.0.2-scaffold.2 → 1.0.2-scaffold.4
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/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +1 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +1 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +72 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +50 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +10 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +134 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +62 -7
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +13 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +42 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +12 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/CopyRequestEvent.kt +28 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/LinkLayoutEvent.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/LinkRenderer.kt +37 -7
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SpanStyleCache.kt +5 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBackgroundSpan.kt +13 -99
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineChipPainter.kt +140 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkChipSpans.kt +177 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt +1 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkStyle.kt +36 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkVariantEntry.kt +7 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +33 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/HTMLGenerator.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/MarkdownExtractor.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLayoutCollector.kt +100 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionActionMode.kt +24 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/views/BlockMenuOptions.kt +27 -8
- package/android/src/main/java/com/swmansion/enriched/markdown/views/CodeBlockContainerView.kt +9 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/views/TableContainerView.kt +18 -2
- package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +3 -1
- package/docs/API_REFERENCE.md +101 -0
- package/docs/COPY_OPTIONS.md +14 -0
- package/docs/MENTIONS.md +8 -1
- package/docs/STYLES.md +27 -0
- package/docs/TEXT.md +2 -0
- package/ios/EnrichedMarkdown.mm +91 -2
- package/ios/EnrichedMarkdownText.mm +64 -3
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +72 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +50 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +10 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +134 -0
- package/ios/internals/MeasurementCache.h +5 -0
- package/ios/renderer/LinkRenderer.m +47 -15
- package/ios/styles/StyleConfig.h +16 -0
- package/ios/styles/StyleConfig.mm +60 -0
- package/ios/utils/CodeBackground.m +3 -65
- package/ios/utils/ENRMBlockMenu.h +12 -3
- package/ios/utils/ENRMChipDrawing.h +24 -0
- package/ios/utils/ENRMChipDrawing.m +83 -0
- package/ios/utils/ENRMLinkChip.h +70 -0
- package/ios/utils/ENRMLinkChip.m +194 -0
- package/ios/utils/ENRMLinkLayout.h +50 -0
- package/ios/utils/ENRMLinkLayout.m +45 -0
- package/ios/utils/EditMenuUtils+macOS.m +4 -1
- package/ios/utils/EditMenuUtils.h +10 -1
- package/ios/utils/EditMenuUtils.m +22 -5
- package/ios/utils/HTMLGenerator.m +2 -1
- package/ios/utils/MarkdownAccessibilityElementBuilder.m +4 -1
- package/ios/utils/MarkdownExtractor.m +2 -1
- package/ios/utils/RTFExportUtils.m +2 -0
- package/ios/utils/StylePropsUtils.h +37 -1
- package/ios/utils/TextViewLayoutManager.mm +3 -0
- package/ios/views/ENRMCodeBlockContainerView.h +4 -0
- package/ios/views/ENRMCodeBlockContainerView.m +8 -1
- package/ios/views/ENRMMathContainerView.h +4 -0
- package/ios/views/ENRMMathContainerView.m +8 -1
- package/ios/views/TableContainerView.h +7 -0
- package/ios/views/TableContainerView.m +30 -3
- package/lib/module/EnrichedMarkdownNativeComponent.ts +57 -0
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +57 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/native/EnrichedMarkdownText.js +119 -9
- package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.js +13 -2
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.web.js +13 -2
- package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
- package/lib/module/web/EnrichedMarkdownText.js +6 -3
- package/lib/module/web/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/web/renderers/InlineRenderers.js +96 -3
- package/lib/module/web/renderers/InlineRenderers.js.map +1 -1
- package/lib/module/web/styles.js +18 -0
- package/lib/module/web/styles.js.map +1 -1
- package/lib/module/web/utils.js +13 -0
- package/lib/module/web/utils.js.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +53 -0
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +53 -0
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +1 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +5 -5
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts +28 -5
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +10 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.d.ts +54 -1
- package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +41 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -1
- package/lib/typescript/src/types/events.d.ts +22 -0
- package/lib/typescript/src/types/events.d.ts.map +1 -1
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts +1 -1
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/InlineRenderers.d.ts.map +1 -1
- package/lib/typescript/src/web/styles.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +4 -0
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/lib/typescript/src/web/utils.d.ts +4 -0
- package/lib/typescript/src/web/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/EnrichedMarkdownNativeComponent.ts +57 -0
- package/src/EnrichedMarkdownTextNativeComponent.ts +57 -0
- package/src/index.tsx +3 -0
- package/src/index.web.tsx +5 -1
- package/src/native/EnrichedMarkdownText.tsx +127 -7
- package/src/normalizeMarkdownStyle.ts +13 -0
- package/src/normalizeMarkdownStyle.web.ts +11 -0
- package/src/types/MarkdownStyle.ts +29 -5
- package/src/types/MarkdownStyleInternal.ts +10 -0
- package/src/types/MarkdownTextProps.ts +56 -0
- package/src/types/MarkdownTextProps.web.ts +43 -1
- package/src/types/events.ts +23 -0
- package/src/web/EnrichedMarkdownText.tsx +10 -3
- package/src/web/renderers/InlineRenderers.tsx +111 -3
- package/src/web/styles.ts +25 -0
- package/src/web/types.ts +4 -0
- package/src/web/utils.ts +8 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,QAAQ,GAChB,UAAU,GACV,WAAW,GACX,MAAM,GACN,MAAM,GACN,SAAS,GACT,WAAW,GACX,WAAW,GACX,QAAQ,GACR,UAAU,GACV,eAAe,GACf,WAAW,GACX,aAAa,GACb,WAAW,GACX,WAAW,GACX,MAAM,GACN,OAAO,GACP,YAAY,GACZ,eAAe,GACf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CAAC,CAAC,CAC/C,CAAC"}
|
|
@@ -11,6 +11,10 @@ export declare function filenameFromUrl(url: string): string;
|
|
|
11
11
|
export declare function indexTaskItems(node: ASTNode, counter?: {
|
|
12
12
|
value: number;
|
|
13
13
|
}): void;
|
|
14
|
+
/** Stamps Link nodes with their document-order index (the `renderLinkDecoration` key). */
|
|
15
|
+
export declare function indexLinks(node: ASTNode, counter?: {
|
|
16
|
+
value: number;
|
|
17
|
+
}): void;
|
|
14
18
|
/**
|
|
15
19
|
* Stamps Image nodes with `isInline` when they appear inside a paragraph
|
|
16
20
|
* that also contains other content (text, links, etc.).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/web/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAIrD;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQnD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO;;CAAe,GAAG,IAAI,CAK1E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAcpD"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/web/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAIrD;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQnD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO;;CAAe,GAAG,IAAI,CAK1E;AAED,0FAA0F;AAC1F,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO;;CAAe,GAAG,IAAI,CAKtE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAcpD"}
|
package/package.json
CHANGED
|
@@ -75,6 +75,11 @@ interface LinkStyleInternal {
|
|
|
75
75
|
color: ColorValue;
|
|
76
76
|
underline: boolean;
|
|
77
77
|
backgroundColor: ColorValue;
|
|
78
|
+
borderRadius: CodegenTypes.Float;
|
|
79
|
+
paddingHorizontal: CodegenTypes.Float;
|
|
80
|
+
paddingVertical: CodegenTypes.Float;
|
|
81
|
+
borderColor: ColorValue;
|
|
82
|
+
borderWidth: CodegenTypes.Float;
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
// Mirrors EnrichedMarkdownTextNativeComponent.ts — kept in sync manually (codegen spec files must be self-contained).
|
|
@@ -83,6 +88,11 @@ interface LinkVariantEntryInternal {
|
|
|
83
88
|
color: ColorValue;
|
|
84
89
|
underline: boolean;
|
|
85
90
|
backgroundColor: ColorValue;
|
|
91
|
+
borderRadius: CodegenTypes.Float;
|
|
92
|
+
paddingHorizontal: CodegenTypes.Float;
|
|
93
|
+
paddingVertical: CodegenTypes.Float;
|
|
94
|
+
borderColor: ColorValue;
|
|
95
|
+
borderWidth: CodegenTypes.Float;
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
interface StrongStyleInternal {
|
|
@@ -245,6 +255,25 @@ export interface LinkLongPressEvent {
|
|
|
245
255
|
url: string;
|
|
246
256
|
}
|
|
247
257
|
|
|
258
|
+
/**
|
|
259
|
+
* `fragments` holds one entry per laid-out line of a link (a wrapping link
|
|
260
|
+
* yields several). Rects are in dp, relative to the native view's origin, and
|
|
261
|
+
* cover the drawn chip (glyphs + padding). Flattened rather than nested per
|
|
262
|
+
* link, and written inline, because codegen only accepts inline object
|
|
263
|
+
* literals as event array elements.
|
|
264
|
+
*/
|
|
265
|
+
export interface LinkLayoutEvent {
|
|
266
|
+
fragments: {
|
|
267
|
+
linkIndex: CodegenTypes.Int32;
|
|
268
|
+
url: string;
|
|
269
|
+
text: string;
|
|
270
|
+
x: CodegenTypes.Double;
|
|
271
|
+
y: CodegenTypes.Double;
|
|
272
|
+
width: CodegenTypes.Double;
|
|
273
|
+
height: CodegenTypes.Double;
|
|
274
|
+
}[];
|
|
275
|
+
}
|
|
276
|
+
|
|
248
277
|
export interface TaskListItemPressEvent {
|
|
249
278
|
index: CodegenTypes.Int32;
|
|
250
279
|
checked: boolean;
|
|
@@ -256,6 +285,14 @@ export interface CopyPressEvent {
|
|
|
256
285
|
language: string;
|
|
257
286
|
}
|
|
258
287
|
|
|
288
|
+
export interface CopyRequestEvent {
|
|
289
|
+
// 'selection' | 'math' | 'table' | 'code'
|
|
290
|
+
source: string;
|
|
291
|
+
markdown: string;
|
|
292
|
+
text: string;
|
|
293
|
+
whole: boolean;
|
|
294
|
+
}
|
|
295
|
+
|
|
259
296
|
export interface ContextMenuItemConfig {
|
|
260
297
|
text: string;
|
|
261
298
|
icon?: string;
|
|
@@ -284,6 +321,8 @@ export interface SelectionMenuConfig {
|
|
|
284
321
|
systemItemsNone: boolean;
|
|
285
322
|
// false hides the copy button in the code block header.
|
|
286
323
|
codeBlockCopyButton: boolean;
|
|
324
|
+
// true: the Copy item emits onCopyRequest instead of writing the clipboard.
|
|
325
|
+
interceptCopy: boolean;
|
|
287
326
|
}
|
|
288
327
|
|
|
289
328
|
export interface OnContextMenuItemPressEvent {
|
|
@@ -390,6 +429,18 @@ export interface NativeProps extends ViewProps {
|
|
|
390
429
|
* - Android: Handles long press gestures on links.
|
|
391
430
|
*/
|
|
392
431
|
onLinkLongPress?: CodegenTypes.BubblingEventHandler<LinkLongPressEvent>;
|
|
432
|
+
/**
|
|
433
|
+
* When true, the view reports the laid-out rects of every link through
|
|
434
|
+
* `onLinkLayout` (after each render and whenever its size changes).
|
|
435
|
+
* Set by the JS wrapper only when `renderLinkDecoration` is provided.
|
|
436
|
+
* @default false
|
|
437
|
+
*/
|
|
438
|
+
emitLinkLayout?: CodegenTypes.WithDefault<boolean, false>;
|
|
439
|
+
/**
|
|
440
|
+
* Fired with the rects of every link fragment while `emitLinkLayout` is on.
|
|
441
|
+
* Deduplicated: not re-fired when the payload is unchanged.
|
|
442
|
+
*/
|
|
443
|
+
onLinkLayout?: CodegenTypes.DirectEventHandler<LinkLayoutEvent>;
|
|
393
444
|
/**
|
|
394
445
|
* Callback fired when a task list checkbox is tapped.
|
|
395
446
|
* Receives the 0-based task index, current checked state, and the item's plain text.
|
|
@@ -410,6 +461,12 @@ export interface NativeProps extends ViewProps {
|
|
|
410
461
|
* action. Receives the copied code and its language.
|
|
411
462
|
*/
|
|
412
463
|
onCopyPress?: CodegenTypes.BubblingEventHandler<CopyPressEvent>;
|
|
464
|
+
/**
|
|
465
|
+
* Fired instead of writing the clipboard when the Copy item of the text
|
|
466
|
+
* selection menu or a table / math / code block menu is pressed while
|
|
467
|
+
* `selectionMenuConfig.interceptCopy` is set.
|
|
468
|
+
*/
|
|
469
|
+
onCopyRequest?: CodegenTypes.BubblingEventHandler<CopyRequestEvent>;
|
|
413
470
|
/**
|
|
414
471
|
* Controls whether the system link preview is shown on long press (iOS only).
|
|
415
472
|
*
|
|
@@ -75,6 +75,11 @@ interface LinkStyleInternal {
|
|
|
75
75
|
color: ColorValue;
|
|
76
76
|
underline: boolean;
|
|
77
77
|
backgroundColor: ColorValue;
|
|
78
|
+
borderRadius: CodegenTypes.Float;
|
|
79
|
+
paddingHorizontal: CodegenTypes.Float;
|
|
80
|
+
paddingVertical: CodegenTypes.Float;
|
|
81
|
+
borderColor: ColorValue;
|
|
82
|
+
borderWidth: CodegenTypes.Float;
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
// Mirrors EnrichedMarkdownNativeComponent.ts — kept in sync manually (codegen spec files must be self-contained).
|
|
@@ -83,6 +88,11 @@ interface LinkVariantEntryInternal {
|
|
|
83
88
|
color: ColorValue;
|
|
84
89
|
underline: boolean;
|
|
85
90
|
backgroundColor: ColorValue;
|
|
91
|
+
borderRadius: CodegenTypes.Float;
|
|
92
|
+
paddingHorizontal: CodegenTypes.Float;
|
|
93
|
+
paddingVertical: CodegenTypes.Float;
|
|
94
|
+
borderColor: ColorValue;
|
|
95
|
+
borderWidth: CodegenTypes.Float;
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
interface StrongStyleInternal {
|
|
@@ -246,6 +256,25 @@ export interface LinkLongPressEvent {
|
|
|
246
256
|
url: string;
|
|
247
257
|
}
|
|
248
258
|
|
|
259
|
+
/**
|
|
260
|
+
* `fragments` holds one entry per laid-out line of a link (a wrapping link
|
|
261
|
+
* yields several). Rects are in dp, relative to the native view's origin, and
|
|
262
|
+
* cover the drawn chip (glyphs + padding). Flattened rather than nested per
|
|
263
|
+
* link, and written inline, because codegen only accepts inline object
|
|
264
|
+
* literals as event array elements.
|
|
265
|
+
*/
|
|
266
|
+
export interface LinkLayoutEvent {
|
|
267
|
+
fragments: {
|
|
268
|
+
linkIndex: CodegenTypes.Int32;
|
|
269
|
+
url: string;
|
|
270
|
+
text: string;
|
|
271
|
+
x: CodegenTypes.Double;
|
|
272
|
+
y: CodegenTypes.Double;
|
|
273
|
+
width: CodegenTypes.Double;
|
|
274
|
+
height: CodegenTypes.Double;
|
|
275
|
+
}[];
|
|
276
|
+
}
|
|
277
|
+
|
|
249
278
|
export interface TaskListItemPressEvent {
|
|
250
279
|
index: CodegenTypes.Int32;
|
|
251
280
|
checked: boolean;
|
|
@@ -257,6 +286,14 @@ export interface CopyPressEvent {
|
|
|
257
286
|
language: string;
|
|
258
287
|
}
|
|
259
288
|
|
|
289
|
+
export interface CopyRequestEvent {
|
|
290
|
+
// 'selection' | 'math' | 'table' | 'code'
|
|
291
|
+
source: string;
|
|
292
|
+
markdown: string;
|
|
293
|
+
text: string;
|
|
294
|
+
whole: boolean;
|
|
295
|
+
}
|
|
296
|
+
|
|
260
297
|
export interface ContextMenuItemConfig {
|
|
261
298
|
text: string;
|
|
262
299
|
icon?: string;
|
|
@@ -285,6 +322,8 @@ export interface SelectionMenuConfig {
|
|
|
285
322
|
systemItemsNone: boolean;
|
|
286
323
|
// false hides the copy button in the code block header.
|
|
287
324
|
codeBlockCopyButton: boolean;
|
|
325
|
+
// true: the Copy item emits onCopyRequest instead of writing the clipboard.
|
|
326
|
+
interceptCopy: boolean;
|
|
288
327
|
}
|
|
289
328
|
|
|
290
329
|
export interface OnContextMenuItemPressEvent {
|
|
@@ -391,6 +430,18 @@ export interface NativeProps extends ViewProps {
|
|
|
391
430
|
* - Android: Handles long press gestures on links.
|
|
392
431
|
*/
|
|
393
432
|
onLinkLongPress?: CodegenTypes.BubblingEventHandler<LinkLongPressEvent>;
|
|
433
|
+
/**
|
|
434
|
+
* When true, the view reports the laid-out rects of every link through
|
|
435
|
+
* `onLinkLayout` (after each render and whenever its size changes).
|
|
436
|
+
* Set by the JS wrapper only when `renderLinkDecoration` is provided.
|
|
437
|
+
* @default false
|
|
438
|
+
*/
|
|
439
|
+
emitLinkLayout?: CodegenTypes.WithDefault<boolean, false>;
|
|
440
|
+
/**
|
|
441
|
+
* Fired with the rects of every link fragment while `emitLinkLayout` is on.
|
|
442
|
+
* Deduplicated: not re-fired when the payload is unchanged.
|
|
443
|
+
*/
|
|
444
|
+
onLinkLayout?: CodegenTypes.DirectEventHandler<LinkLayoutEvent>;
|
|
394
445
|
/**
|
|
395
446
|
* Callback fired when a task list checkbox is tapped.
|
|
396
447
|
* Receives the 0-based task index, current checked state, and the item's plain text.
|
|
@@ -411,6 +462,12 @@ export interface NativeProps extends ViewProps {
|
|
|
411
462
|
* action. Receives the copied code and its language.
|
|
412
463
|
*/
|
|
413
464
|
onCopyPress?: CodegenTypes.BubblingEventHandler<CopyPressEvent>;
|
|
465
|
+
/**
|
|
466
|
+
* Fired instead of writing the clipboard when the Copy item of the text
|
|
467
|
+
* selection menu or a table / math / code block menu is pressed while
|
|
468
|
+
* `selectionMenuConfig.interceptCopy` is set.
|
|
469
|
+
*/
|
|
470
|
+
onCopyRequest?: CodegenTypes.BubblingEventHandler<CopyRequestEvent>;
|
|
414
471
|
/**
|
|
415
472
|
* Controls whether the system link preview is shown on long press (iOS only).
|
|
416
473
|
*
|
package/src/index.tsx
CHANGED
|
@@ -7,12 +7,15 @@ export type {
|
|
|
7
7
|
ContextMenuItem as TextContextMenuItem,
|
|
8
8
|
SelectionMenuConfig as TextSelectionMenuConfig,
|
|
9
9
|
SelectionMenuPluralLabels as TextSelectionMenuPluralLabels,
|
|
10
|
+
LinkDecorationInfo,
|
|
11
|
+
LinkRect,
|
|
10
12
|
} from './native/EnrichedMarkdownText';
|
|
11
13
|
export type {
|
|
12
14
|
LinkPressEvent,
|
|
13
15
|
LinkLongPressEvent,
|
|
14
16
|
TaskListItemPressEvent,
|
|
15
17
|
CopyPressEvent,
|
|
18
|
+
CopyEvent,
|
|
16
19
|
OnPasteEvent,
|
|
17
20
|
} from './types/events';
|
|
18
21
|
export type {
|
package/src/index.web.tsx
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { EnrichedMarkdownText, default } from './web/EnrichedMarkdownText';
|
|
2
|
-
export type {
|
|
2
|
+
export type {
|
|
3
|
+
EnrichedMarkdownTextProps,
|
|
4
|
+
LinkDecorationInfo,
|
|
5
|
+
LinkRect,
|
|
6
|
+
} from './types/MarkdownTextProps.web';
|
|
3
7
|
export type { MarkdownStyle, Md4cFlags } from './types/MarkdownStyle';
|
|
4
8
|
export type {
|
|
5
9
|
LinkPressEvent,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { useMemo, useCallback, useRef, useEffect } from 'react';
|
|
1
|
+
import { useMemo, useCallback, useRef, useEffect, useState } from 'react';
|
|
2
2
|
import EnrichedMarkdownTextNativeComponent from '../EnrichedMarkdownTextNativeComponent';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
LinkLayoutEvent,
|
|
5
|
+
MarkdownStyleInternal,
|
|
6
|
+
} from '../EnrichedMarkdownTextNativeComponent';
|
|
4
7
|
import EnrichedMarkdownNativeComponent from '../EnrichedMarkdownNativeComponent';
|
|
5
8
|
import { normalizeMarkdownStyle } from '../normalizeMarkdownStyle';
|
|
6
9
|
import { resolveAccessibilityLabels } from '../accessibilityLabelDefaults';
|
|
@@ -8,7 +11,8 @@ import {
|
|
|
8
11
|
normalizeMenuItem,
|
|
9
12
|
normalizeLegacyBooleanMenuItem,
|
|
10
13
|
} from '../normalizeMenuItem';
|
|
11
|
-
import
|
|
14
|
+
import { StyleSheet, View } from 'react-native';
|
|
15
|
+
import type { LayoutChangeEvent, NativeSyntheticEvent } from 'react-native';
|
|
12
16
|
import type { MarkdownStyle, Md4cFlags } from '../types/MarkdownStyle';
|
|
13
17
|
import type {
|
|
14
18
|
EnrichedMarkdownTextProps,
|
|
@@ -16,12 +20,15 @@ import type {
|
|
|
16
20
|
ContextMenuItem,
|
|
17
21
|
SelectionMenuConfig,
|
|
18
22
|
SelectionMenuPluralLabels,
|
|
23
|
+
LinkDecorationInfo,
|
|
24
|
+
LinkRect,
|
|
19
25
|
} from '../types/MarkdownTextProps';
|
|
20
26
|
import type {
|
|
21
27
|
LinkPressEvent,
|
|
22
28
|
LinkLongPressEvent,
|
|
23
29
|
TaskListItemPressEvent,
|
|
24
30
|
CopyPressEvent,
|
|
31
|
+
CopyEvent,
|
|
25
32
|
OnContextMenuItemPressEvent,
|
|
26
33
|
} from '../types/events';
|
|
27
34
|
|
|
@@ -32,12 +39,15 @@ export type {
|
|
|
32
39
|
ContextMenuItem,
|
|
33
40
|
SelectionMenuConfig,
|
|
34
41
|
SelectionMenuPluralLabels,
|
|
42
|
+
LinkDecorationInfo,
|
|
43
|
+
LinkRect,
|
|
35
44
|
};
|
|
36
45
|
export type {
|
|
37
46
|
LinkPressEvent,
|
|
38
47
|
LinkLongPressEvent,
|
|
39
48
|
TaskListItemPressEvent,
|
|
40
49
|
CopyPressEvent,
|
|
50
|
+
CopyEvent,
|
|
41
51
|
};
|
|
42
52
|
|
|
43
53
|
// Default English labels for the built-in selection menu actions. Defaults are
|
|
@@ -101,6 +111,34 @@ const buildPluralTemplates = (
|
|
|
101
111
|
return templates;
|
|
102
112
|
};
|
|
103
113
|
|
|
114
|
+
type LinkLayoutFragment = LinkLayoutEvent['fragments'][number];
|
|
115
|
+
|
|
116
|
+
/** Groups the flat per-line fragments native reports into one entry per link. */
|
|
117
|
+
const groupLinkFragments = (
|
|
118
|
+
fragments: ReadonlyArray<LinkLayoutFragment>
|
|
119
|
+
): LinkDecorationInfo[] => {
|
|
120
|
+
const byIndex = new Map<number, LinkDecorationInfo>();
|
|
121
|
+
for (const { linkIndex, url, text, x, y, width, height } of fragments) {
|
|
122
|
+
const rect: LinkRect = { x, y, width, height };
|
|
123
|
+
const info = byIndex.get(linkIndex);
|
|
124
|
+
if (info) {
|
|
125
|
+
info.rects.push(rect);
|
|
126
|
+
info.rect = rect;
|
|
127
|
+
} else {
|
|
128
|
+
byIndex.set(linkIndex, {
|
|
129
|
+
index: linkIndex,
|
|
130
|
+
url,
|
|
131
|
+
text,
|
|
132
|
+
rect,
|
|
133
|
+
rects: [rect],
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return [...byIndex.values()];
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const ZERO_OFFSET = { x: 0, y: 0 };
|
|
141
|
+
|
|
104
142
|
const defaultMd4cFlags: Md4cFlags = {
|
|
105
143
|
underline: false,
|
|
106
144
|
superscript: false,
|
|
@@ -119,6 +157,7 @@ export const EnrichedMarkdownText = ({
|
|
|
119
157
|
onTaskListItemPress,
|
|
120
158
|
enableTaskListItemToggle = true,
|
|
121
159
|
onCopyPress,
|
|
160
|
+
onCopy,
|
|
122
161
|
enableLinkPreview,
|
|
123
162
|
selectable = true,
|
|
124
163
|
md4cFlags = defaultMd4cFlags,
|
|
@@ -139,6 +178,8 @@ export const EnrichedMarkdownText = ({
|
|
|
139
178
|
textBreakStrategy,
|
|
140
179
|
lineBreakStrategyIOS,
|
|
141
180
|
writingDirection = 'first-strong',
|
|
181
|
+
renderLinkDecoration,
|
|
182
|
+
onLayout,
|
|
142
183
|
...rest
|
|
143
184
|
}: EnrichedMarkdownTextProps) => {
|
|
144
185
|
const normalizedStyleRef = useRef<MarkdownStyleInternal | null>(null);
|
|
@@ -239,6 +280,41 @@ export const EnrichedMarkdownText = ({
|
|
|
239
280
|
[onCopyPress]
|
|
240
281
|
);
|
|
241
282
|
|
|
283
|
+
const handleCopyRequest = useCallback(
|
|
284
|
+
// Codegen types `source` as a plain string; native only sends the four
|
|
285
|
+
// values of CopyEvent['source'].
|
|
286
|
+
(
|
|
287
|
+
e: NativeSyntheticEvent<Omit<CopyEvent, 'source'> & { source: string }>
|
|
288
|
+
) => {
|
|
289
|
+
const { source, markdown: copied, text, whole } = e.nativeEvent;
|
|
290
|
+
onCopy?.({
|
|
291
|
+
source: source as CopyEvent['source'],
|
|
292
|
+
markdown: copied,
|
|
293
|
+
text,
|
|
294
|
+
whole,
|
|
295
|
+
});
|
|
296
|
+
},
|
|
297
|
+
[onCopy]
|
|
298
|
+
);
|
|
299
|
+
const interceptCopy = onCopy != null;
|
|
300
|
+
|
|
301
|
+
const decorated = renderLinkDecoration != null;
|
|
302
|
+
const [linkLayout, setLinkLayout] = useState<LinkDecorationInfo[]>([]);
|
|
303
|
+
// Where the native view sits inside the wrapper (the wrapper's padding).
|
|
304
|
+
const [nativeOffset, setNativeOffset] = useState(ZERO_OFFSET);
|
|
305
|
+
|
|
306
|
+
const handleLinkLayout = useCallback(
|
|
307
|
+
(e: NativeSyntheticEvent<LinkLayoutEvent>) => {
|
|
308
|
+
setLinkLayout(groupLinkFragments(e.nativeEvent.fragments));
|
|
309
|
+
},
|
|
310
|
+
[]
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
const handleNativeLayout = useCallback((e: LayoutChangeEvent) => {
|
|
314
|
+
const { x, y } = e.nativeEvent.layout;
|
|
315
|
+
setNativeOffset((prev) => (prev.x === x && prev.y === y ? prev : { x, y }));
|
|
316
|
+
}, []);
|
|
317
|
+
|
|
242
318
|
const tableMode = streamingConfig?.tableMode ?? 'progressive';
|
|
243
319
|
const codeBlockMode = streamingConfig?.codeBlockMode ?? 'progressive';
|
|
244
320
|
const normalizedStreamingConfig = useMemo(
|
|
@@ -302,8 +378,9 @@ export const EnrichedMarkdownText = ({
|
|
|
302
378
|
copyFormatMarkdown: copyFormat === 'markdown',
|
|
303
379
|
systemItemsNone: config?.systemItems === 'none',
|
|
304
380
|
codeBlockCopyButton: codeBlockCopyButton.enabled,
|
|
381
|
+
interceptCopy,
|
|
305
382
|
};
|
|
306
|
-
}, [selectionMenuConfig]);
|
|
383
|
+
}, [selectionMenuConfig, interceptCopy]);
|
|
307
384
|
|
|
308
385
|
const resolvedAccessibilityLabels = useMemo(
|
|
309
386
|
() => resolveAccessibilityLabels(accessibilityLabels),
|
|
@@ -318,6 +395,7 @@ export const EnrichedMarkdownText = ({
|
|
|
318
395
|
onTaskListItemPress: handleTaskListItemPress,
|
|
319
396
|
enableTaskListItemToggle,
|
|
320
397
|
onCopyPress: handleCopyPress,
|
|
398
|
+
onCopyRequest: handleCopyRequest,
|
|
321
399
|
enableLinkPreview: onLinkLongPress == null && (enableLinkPreview ?? true),
|
|
322
400
|
selectable,
|
|
323
401
|
md4cFlags: normalizedMd4cFlags,
|
|
@@ -342,11 +420,53 @@ export const EnrichedMarkdownText = ({
|
|
|
342
420
|
...rest,
|
|
343
421
|
};
|
|
344
422
|
|
|
345
|
-
|
|
346
|
-
|
|
423
|
+
const NativeComponent =
|
|
424
|
+
flavor === 'github'
|
|
425
|
+
? EnrichedMarkdownNativeComponent
|
|
426
|
+
: EnrichedMarkdownTextNativeComponent;
|
|
427
|
+
|
|
428
|
+
// Without decorations the native view is returned as-is (no wrapper, no
|
|
429
|
+
// layout events) so existing layouts are untouched.
|
|
430
|
+
if (!decorated) {
|
|
431
|
+
return <NativeComponent {...sharedProps} onLayout={onLayout} />;
|
|
347
432
|
}
|
|
348
433
|
|
|
349
|
-
return
|
|
434
|
+
return (
|
|
435
|
+
<View style={containerStyle} onLayout={onLayout}>
|
|
436
|
+
<NativeComponent
|
|
437
|
+
{...sharedProps}
|
|
438
|
+
style={undefined}
|
|
439
|
+
emitLinkLayout
|
|
440
|
+
onLinkLayout={handleLinkLayout}
|
|
441
|
+
onLayout={handleNativeLayout}
|
|
442
|
+
/>
|
|
443
|
+
{linkLayout.map((info) => {
|
|
444
|
+
const decoration = renderLinkDecoration(info);
|
|
445
|
+
if (decoration == null) return null;
|
|
446
|
+
return (
|
|
447
|
+
<View
|
|
448
|
+
key={info.index}
|
|
449
|
+
pointerEvents="box-none"
|
|
450
|
+
style={[
|
|
451
|
+
styles.decoration,
|
|
452
|
+
{
|
|
453
|
+
left: nativeOffset.x + info.rect.x,
|
|
454
|
+
top: nativeOffset.y + info.rect.y,
|
|
455
|
+
width: info.rect.width,
|
|
456
|
+
height: info.rect.height,
|
|
457
|
+
},
|
|
458
|
+
]}
|
|
459
|
+
>
|
|
460
|
+
{decoration}
|
|
461
|
+
</View>
|
|
462
|
+
);
|
|
463
|
+
})}
|
|
464
|
+
</View>
|
|
465
|
+
);
|
|
350
466
|
};
|
|
351
467
|
|
|
468
|
+
const styles = StyleSheet.create({
|
|
469
|
+
decoration: { position: 'absolute' },
|
|
470
|
+
});
|
|
471
|
+
|
|
352
472
|
export default EnrichedMarkdownText;
|
|
@@ -183,6 +183,11 @@ const DEFAULT_NORMALIZED_STYLE = Object.freeze({
|
|
|
183
183
|
color: normalizeColor('#2563EB')!,
|
|
184
184
|
underline: true,
|
|
185
185
|
backgroundColor: normalizeColor('transparent')!,
|
|
186
|
+
borderRadius: 0,
|
|
187
|
+
paddingHorizontal: 0,
|
|
188
|
+
paddingVertical: 0,
|
|
189
|
+
borderColor: normalizeColor('transparent')!,
|
|
190
|
+
borderWidth: 0,
|
|
186
191
|
},
|
|
187
192
|
linkVariants: [],
|
|
188
193
|
strong: { fontFamily: '', fontWeight: 'bold', color: undefined },
|
|
@@ -338,9 +343,17 @@ export const normalizeMarkdownStyle = (
|
|
|
338
343
|
color: ((override.color ? normalizeColor(override.color) : null) ??
|
|
339
344
|
linkBase.color) as string,
|
|
340
345
|
underline: override.underline ?? linkBase.underline,
|
|
346
|
+
// Chip ("box") properties never inherit from the base link style.
|
|
341
347
|
backgroundColor: (override.backgroundColor
|
|
342
348
|
? (normalizeColor(override.backgroundColor) ?? transparent)
|
|
343
349
|
: transparent) as string,
|
|
350
|
+
borderRadius: override.borderRadius ?? 0,
|
|
351
|
+
paddingHorizontal: override.paddingHorizontal ?? 0,
|
|
352
|
+
paddingVertical: override.paddingVertical ?? 0,
|
|
353
|
+
borderColor: (override.borderColor
|
|
354
|
+
? (normalizeColor(override.borderColor) ?? transparent)
|
|
355
|
+
: transparent) as string,
|
|
356
|
+
borderWidth: override.borderWidth ?? 0,
|
|
344
357
|
};
|
|
345
358
|
}
|
|
346
359
|
);
|
|
@@ -147,6 +147,11 @@ const DEFAULT_NORMALIZED_STYLE: MarkdownStyleInternal = Object.freeze({
|
|
|
147
147
|
color: '#2563EB',
|
|
148
148
|
underline: true,
|
|
149
149
|
backgroundColor: 'transparent',
|
|
150
|
+
borderRadius: 0,
|
|
151
|
+
paddingHorizontal: 0,
|
|
152
|
+
paddingVertical: 0,
|
|
153
|
+
borderColor: 'transparent',
|
|
154
|
+
borderWidth: 0,
|
|
150
155
|
},
|
|
151
156
|
linkVariants: [],
|
|
152
157
|
strong: { fontFamily: '', fontWeight: 'bold', color: undefined },
|
|
@@ -289,7 +294,13 @@ export const normalizeMarkdownStyle = (
|
|
|
289
294
|
pattern,
|
|
290
295
|
color: override.color ?? linkBase.color,
|
|
291
296
|
underline: override.underline ?? linkBase.underline,
|
|
297
|
+
// Chip ("box") properties never inherit from the base link style.
|
|
292
298
|
backgroundColor: override.backgroundColor ?? 'transparent',
|
|
299
|
+
borderRadius: override.borderRadius ?? 0,
|
|
300
|
+
paddingHorizontal: override.paddingHorizontal ?? 0,
|
|
301
|
+
paddingVertical: override.paddingVertical ?? 0,
|
|
302
|
+
borderColor: override.borderColor ?? 'transparent',
|
|
303
|
+
borderWidth: override.borderWidth ?? 0,
|
|
293
304
|
};
|
|
294
305
|
}
|
|
295
306
|
);
|
|
@@ -84,17 +84,39 @@ interface CodeBlockStyle extends BaseBlockStyle {
|
|
|
84
84
|
syntaxColors?: CodeBlockSyntaxColors;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Chip ("box") properties shared by `link` and `linkVariants`. Unlike `color`
|
|
89
|
+
* and `underline`, these never inherit from the base `link` style: a variant
|
|
90
|
+
* that omits them renders without a chip (`0` / `transparent`).
|
|
91
|
+
*/
|
|
92
|
+
interface LinkChipStyle {
|
|
93
|
+
backgroundColor?: string;
|
|
94
|
+
/** Corner radius of the chip, in dp. */
|
|
95
|
+
borderRadius?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Horizontal padding, in dp. Reserves real space in the line on both outer
|
|
98
|
+
* edges of the link (affects measurement and wrapping).
|
|
99
|
+
*/
|
|
100
|
+
paddingHorizontal?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Vertical padding, in dp. Only affects the drawn chip (it bleeds into the
|
|
103
|
+
* surrounding line spacing); the line box is unchanged.
|
|
104
|
+
*/
|
|
105
|
+
paddingVertical?: number;
|
|
106
|
+
borderColor?: string;
|
|
107
|
+
/** Border width, in dp. Drawn inset, within the chip bounds. */
|
|
108
|
+
borderWidth?: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface LinkStyle extends LinkChipStyle {
|
|
88
112
|
fontFamily?: string;
|
|
89
113
|
color?: string;
|
|
90
114
|
underline?: boolean;
|
|
91
|
-
backgroundColor?: string;
|
|
92
115
|
}
|
|
93
116
|
|
|
94
|
-
export interface LinkVariantStyle {
|
|
117
|
+
export interface LinkVariantStyle extends LinkChipStyle {
|
|
95
118
|
color?: string;
|
|
96
119
|
underline?: boolean;
|
|
97
|
-
backgroundColor?: string;
|
|
98
120
|
}
|
|
99
121
|
|
|
100
122
|
interface StrongStyle {
|
|
@@ -350,7 +372,9 @@ export interface MarkdownStyle {
|
|
|
350
372
|
* specific patterns take precedence.
|
|
351
373
|
*
|
|
352
374
|
* `color` and `underline` inherit from the base `link` style when omitted.
|
|
353
|
-
* `backgroundColor`
|
|
375
|
+
* Chip properties (`backgroundColor`, `borderRadius`, `paddingHorizontal`,
|
|
376
|
+
* `paddingVertical`, `borderColor`, `borderWidth`) do not inherit: when
|
|
377
|
+
* omitted they default to `0` / `transparent`.
|
|
354
378
|
* `fontFamily` always follows the base `link` style and cannot be overridden per-variant.
|
|
355
379
|
*
|
|
356
380
|
* @example
|
|
@@ -88,6 +88,11 @@ interface LinkStyleInternal {
|
|
|
88
88
|
color: string;
|
|
89
89
|
underline: boolean;
|
|
90
90
|
backgroundColor: string;
|
|
91
|
+
borderRadius: number;
|
|
92
|
+
paddingHorizontal: number;
|
|
93
|
+
paddingVertical: number;
|
|
94
|
+
borderColor: string;
|
|
95
|
+
borderWidth: number;
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
export interface LinkVariantEntryInternal {
|
|
@@ -95,6 +100,11 @@ export interface LinkVariantEntryInternal {
|
|
|
95
100
|
color: string;
|
|
96
101
|
underline: boolean;
|
|
97
102
|
backgroundColor: string;
|
|
103
|
+
borderRadius: number;
|
|
104
|
+
paddingHorizontal: number;
|
|
105
|
+
paddingVertical: number;
|
|
106
|
+
borderColor: string;
|
|
107
|
+
borderWidth: number;
|
|
98
108
|
}
|
|
99
109
|
|
|
100
110
|
interface StrongStyleInternal {
|