react-native-enriched-markdown-scaffold 1.0.2-scaffold.3 → 1.0.2-scaffold.5
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 +15 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +15 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +3 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +122 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +100 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +20 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +124 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +145 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +19 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +22 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +85 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +22 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/LinkLayoutEvent.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/SelectionChangeEvent.kt +42 -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 +28 -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 +4 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionChangeReporter.kt +230 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/CodeBlockContainerView.kt +11 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/views/TableContainerView.kt +22 -1
- package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +8 -1
- package/docs/API_REFERENCE.md +111 -0
- package/docs/MENTIONS.md +8 -1
- package/docs/STYLES.md +27 -0
- package/docs/TEXT.md +2 -0
- package/ios/EnrichedMarkdown.mm +221 -1
- package/ios/EnrichedMarkdownText.mm +142 -1
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +122 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +100 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +20 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +124 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/RCTComponentViewHelpers.h +50 -2
- 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/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/ENRMSelectionChange.h +96 -0
- package/ios/utils/ENRMSelectionChange.m +204 -0
- package/ios/utils/EditMenuUtils+macOS.m +4 -1
- package/ios/utils/EditMenuUtils.m +4 -1
- package/ios/utils/HTMLGenerator.m +2 -1
- package/ios/utils/MarkdownAccessibilityElementBuilder.m +3 -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 +3 -0
- package/ios/views/ENRMCodeBlockContainerView.m +3 -0
- package/ios/views/ENRMMathContainerView.h +3 -0
- package/ios/views/ENRMMathContainerView.m +3 -0
- package/ios/views/TableContainerView.h +6 -0
- package/ios/views/TableContainerView.m +24 -0
- package/lib/module/EnrichedMarkdownNativeComponent.ts +101 -1
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +101 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +13 -0
- package/lib/module/jest/index.js.map +1 -1
- package/lib/module/native/EnrichedMarkdownText.js +138 -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 +93 -2
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +93 -2
- 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/jest/index.d.ts +1 -1
- package/lib/typescript/src/jest/index.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 +76 -2
- 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 +36 -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 +101 -1
- package/src/EnrichedMarkdownTextNativeComponent.ts +101 -1
- package/src/index.tsx +5 -0
- package/src/index.web.tsx +5 -1
- package/src/jest/index.tsx +21 -1
- package/src/native/EnrichedMarkdownText.tsx +181 -8
- 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 +85 -1
- package/src/types/MarkdownTextProps.web.ts +43 -1
- package/src/types/events.ts +38 -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,7 +1,45 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode, RefObject } from 'react';
|
|
2
|
+
import type { ColorValue, HostInstance, ViewProps, ViewStyle, TextStyle } from 'react-native';
|
|
2
3
|
import type { MarkdownStyle, Md4cFlags } from './MarkdownStyle';
|
|
3
4
|
import type { AccessibilityLabels } from './AccessibilityLabels';
|
|
4
|
-
import type { LinkPressEvent, LinkLongPressEvent, TaskListItemPressEvent, CopyPressEvent, CopyEvent } from './events';
|
|
5
|
+
import type { LinkPressEvent, LinkLongPressEvent, TaskListItemPressEvent, CopyPressEvent, CopyEvent, SelectionChangeEvent } from './events';
|
|
6
|
+
/** Imperative handle of `EnrichedMarkdownText`, reached through its `ref`. */
|
|
7
|
+
export interface EnrichedMarkdownTextInstance {
|
|
8
|
+
/**
|
|
9
|
+
* Clears the text selection (and any long-pressed block) and fires
|
|
10
|
+
* `onSelectionChange` with `active: false`.
|
|
11
|
+
* @platform ios, android
|
|
12
|
+
*/
|
|
13
|
+
clearSelection: () => void;
|
|
14
|
+
measure: HostInstance['measure'];
|
|
15
|
+
measureInWindow: HostInstance['measureInWindow'];
|
|
16
|
+
measureLayout: HostInstance['measureLayout'];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A rect in dp, relative to the component's content box (inside any
|
|
20
|
+
* `containerStyle` padding).
|
|
21
|
+
*/
|
|
22
|
+
export interface LinkRect {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
}
|
|
28
|
+
/** Layout of one rendered link, passed to `renderLinkDecoration`. */
|
|
29
|
+
export interface LinkDecorationInfo {
|
|
30
|
+
/** Position of the link in the document (0-based) — stable key for a link. */
|
|
31
|
+
index: number;
|
|
32
|
+
url: string;
|
|
33
|
+
/** The link's visible text. */
|
|
34
|
+
text: string;
|
|
35
|
+
/**
|
|
36
|
+
* Anchor rect. Native: the drawn chip (glyphs + padding) of the link's last
|
|
37
|
+
* line fragment. Web: the link's inline box.
|
|
38
|
+
*/
|
|
39
|
+
rect: LinkRect;
|
|
40
|
+
/** Every line fragment of the link (several when it wraps). Web: `[rect]`. */
|
|
41
|
+
rects: LinkRect[];
|
|
42
|
+
}
|
|
5
43
|
/**
|
|
6
44
|
* Public context menu item. Each item includes a JS-side `onPress` callback
|
|
7
45
|
* that is called when the user taps the item in the selection context menu.
|
|
@@ -142,6 +180,11 @@ export interface StreamingConfig {
|
|
|
142
180
|
codeBlockMode?: 'hidden' | 'progressive';
|
|
143
181
|
}
|
|
144
182
|
export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
|
|
183
|
+
/**
|
|
184
|
+
* Imperative handle: `clearSelection()` plus the host `measure*` methods.
|
|
185
|
+
* @platform ios, android
|
|
186
|
+
*/
|
|
187
|
+
ref?: RefObject<EnrichedMarkdownTextInstance | null>;
|
|
145
188
|
/**
|
|
146
189
|
* Markdown content to render.
|
|
147
190
|
* @platform ios, android, web
|
|
@@ -179,6 +222,21 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
|
|
|
179
222
|
* @platform ios, android, web
|
|
180
223
|
*/
|
|
181
224
|
onLinkLongPress?: (event: LinkLongPressEvent) => void;
|
|
225
|
+
/**
|
|
226
|
+
* Renders a decoration (e.g. a badge or icon) over each link. The returned
|
|
227
|
+
* node is placed in an absolutely positioned box matching `info.rect` (the
|
|
228
|
+
* link's last line fragment, including chip padding) with
|
|
229
|
+
* `pointerEvents="box-none"`; position content relative to it (negative
|
|
230
|
+
* offsets overflow the box). Return `null` to leave a link undecorated.
|
|
231
|
+
*
|
|
232
|
+
* Native caveats: rects arrive from native after layout, so decorations
|
|
233
|
+
* appear one frame after the text; links inside tables (`flavor="github"`)
|
|
234
|
+
* are not reported; content overflowing the component bounds does not
|
|
235
|
+
* receive touches on Android. Toggling this prop between set and unset
|
|
236
|
+
* remounts the native view.
|
|
237
|
+
* @platform ios, android, web
|
|
238
|
+
*/
|
|
239
|
+
renderLinkDecoration?: (info: LinkDecorationInfo) => ReactNode | null;
|
|
182
240
|
/**
|
|
183
241
|
* Callback fired when a task list checkbox is tapped.
|
|
184
242
|
*
|
|
@@ -227,6 +285,22 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
|
|
|
227
285
|
* @platform ios, android
|
|
228
286
|
*/
|
|
229
287
|
onCopy?: (event: CopyEvent) => void;
|
|
288
|
+
/**
|
|
289
|
+
* Reports the text selection so the app can draw its own menu (pair it with
|
|
290
|
+
* `contextMenuHidden`). Fires at most once per frame while the selection
|
|
291
|
+
* changes, and with `active: false` once it is gone. With
|
|
292
|
+
* `contextMenuHidden`, a long press on a table / math / code block fires it
|
|
293
|
+
* too (`source` is the block kind, `whole: true`), since those blocks have no
|
|
294
|
+
* text selection of their own. Only one part of a component holds a
|
|
295
|
+
* selection at a time; clearing the selection of *other* components is up to
|
|
296
|
+
* the app (`ref.current.clearSelection()`).
|
|
297
|
+
*
|
|
298
|
+
* Rects are relative to the view that `ref.current.measureInWindow`
|
|
299
|
+
* measures — add that origin to position UI on screen. There is no
|
|
300
|
+
* "dragging" flag: debounce before showing a menu.
|
|
301
|
+
* @platform ios, android
|
|
302
|
+
*/
|
|
303
|
+
onSelectionChange?: (event: SelectionChangeEvent) => void;
|
|
230
304
|
/**
|
|
231
305
|
* Controls whether the system link preview is shown on long press (iOS only).
|
|
232
306
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownTextProps.d.ts","sourceRoot":"","sources":["../../../../src/types/MarkdownTextProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"MarkdownTextProps.d.ts","sourceRoot":"","sources":["../../../../src/types/MarkdownTextProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACd,SAAS,EACT,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAElB,8EAA8E;AAC9E,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,eAAe,EA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C,EAAE,eAAe,EAAE,CAAC;IACrC;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C;;;;;;;;;;;;;;OAcG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C;;;;;OAKG;IACH,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAC7B;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,EAAE,QAAQ,GAAG,aAAa,GAAG,UAAU,CAAC;IAC1D;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,aAAa,GAAG,UAAU,CAAC;IACxE;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,cAAc,CAAC;CAC5D"}
|
|
@@ -1,6 +1,31 @@
|
|
|
1
|
-
import type { CSSProperties, HTMLAttributes } from 'react';
|
|
1
|
+
import type { CSSProperties, HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import type { MarkdownStyle, Md4cFlags } from './MarkdownStyle';
|
|
3
3
|
import type { LinkPressEvent, LinkLongPressEvent, TaskListItemPressEvent } from './events';
|
|
4
|
+
/**
|
|
5
|
+
* A rect in dp, relative to the component's content box (inside any
|
|
6
|
+
* `containerStyle` padding).
|
|
7
|
+
*/
|
|
8
|
+
export interface LinkRect {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
14
|
+
/** Layout of one rendered link, passed to `renderLinkDecoration`. */
|
|
15
|
+
export interface LinkDecorationInfo {
|
|
16
|
+
/** Position of the link in the document (0-based) — stable key for a link. */
|
|
17
|
+
index: number;
|
|
18
|
+
url: string;
|
|
19
|
+
/** The link's visible text. */
|
|
20
|
+
text: string;
|
|
21
|
+
/**
|
|
22
|
+
* Anchor rect. Native: the drawn chip (glyphs + padding) of the link's last
|
|
23
|
+
* line fragment. Web: the link's inline box.
|
|
24
|
+
*/
|
|
25
|
+
rect: LinkRect;
|
|
26
|
+
/** Every line fragment of the link (several when it wraps). Web: `[rect]`. */
|
|
27
|
+
rects: LinkRect[];
|
|
28
|
+
}
|
|
4
29
|
export interface EnrichedMarkdownTextProps extends Omit<HTMLAttributes<HTMLDivElement>, 'style' | 'dir'> {
|
|
5
30
|
/**
|
|
6
31
|
* Markdown content to render.
|
|
@@ -39,6 +64,21 @@ export interface EnrichedMarkdownTextProps extends Omit<HTMLAttributes<HTMLDivEl
|
|
|
39
64
|
* @platform ios, android, web
|
|
40
65
|
*/
|
|
41
66
|
onLinkLongPress?: (event: LinkLongPressEvent) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Renders a decoration (e.g. a badge or icon) over each link. The returned
|
|
69
|
+
* node is placed in an absolutely positioned box matching `info.rect` (the
|
|
70
|
+
* link's last line fragment, including chip padding) with
|
|
71
|
+
* `pointerEvents="box-none"`; position content relative to it (negative
|
|
72
|
+
* offsets overflow the box). Return `null` to leave a link undecorated.
|
|
73
|
+
*
|
|
74
|
+
* Native caveats: rects arrive from native after layout, so decorations
|
|
75
|
+
* appear one frame after the text; links inside tables (`flavor="github"`)
|
|
76
|
+
* are not reported; content overflowing the component bounds does not
|
|
77
|
+
* receive touches on Android. Toggling this prop between set and unset
|
|
78
|
+
* remounts the native view.
|
|
79
|
+
* @platform ios, android, web
|
|
80
|
+
*/
|
|
81
|
+
renderLinkDecoration?: (info: LinkDecorationInfo) => ReactNode | null;
|
|
42
82
|
/**
|
|
43
83
|
* Callback fired when a task list checkbox is tapped.
|
|
44
84
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownTextProps.web.d.ts","sourceRoot":"","sources":["../../../../src/types/MarkdownTextProps.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MarkdownTextProps.web.d.ts","sourceRoot":"","sources":["../../../../src/types/MarkdownTextProps.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAElB;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf,8EAA8E;IAC9E,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,yBAA0B,SAAQ,IAAI,CACrD,cAAc,CAAC,cAAc,CAAC,EAC9B,OAAO,GAAG,KAAK,CAChB;IACC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;OAGG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACtD;;;;;;;;;;;;;OAaG;IACH,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,SAAS,GAAG,IAAI,CAAC;IACtE;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC9D;;;;;;;;;;;;;;;;;OAiBG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;OAKG;IACH,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;CAC9B"}
|
|
@@ -35,6 +35,42 @@ export interface CopyEvent {
|
|
|
35
35
|
*/
|
|
36
36
|
whole: boolean;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* A rect in dp, relative to the component's native view: add the origin from
|
|
40
|
+
* the component ref's `measureInWindow` to get window coordinates.
|
|
41
|
+
*/
|
|
42
|
+
export interface SelectionRect {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Payload of `onSelectionChange`: the current text selection, or a table /
|
|
50
|
+
* math / code block long-pressed while `contextMenuHidden` is on. Content
|
|
51
|
+
* fields carry what `onCopy` would receive for the same selection.
|
|
52
|
+
*/
|
|
53
|
+
export interface SelectionChangeEvent {
|
|
54
|
+
/** `false` once the selection is gone; every other field is then empty / zero. */
|
|
55
|
+
active: boolean;
|
|
56
|
+
/** `'selection'` for text; the block kind for a long-pressed block. */
|
|
57
|
+
source: CopyEvent['source'];
|
|
58
|
+
/** Rendered text of the selection, or the block's raw content. */
|
|
59
|
+
text: string;
|
|
60
|
+
/** Same as `CopyEvent.markdown` for this selection. */
|
|
61
|
+
markdown: string;
|
|
62
|
+
/** Same as `CopyEvent.whole`. Always `true` for blocks. */
|
|
63
|
+
whole: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Bounding box of the selection (full content width when it spans several
|
|
66
|
+
* lines); the block's frame for blocks.
|
|
67
|
+
*/
|
|
68
|
+
rect: SelectionRect;
|
|
69
|
+
/** Selected part of the first line (block: same as `rect`). */
|
|
70
|
+
startRect: SelectionRect;
|
|
71
|
+
/** Selected part of the last line (block: same as `rect`). */
|
|
72
|
+
endRect: SelectionRect;
|
|
73
|
+
}
|
|
38
74
|
/**
|
|
39
75
|
* Native-level context menu item config sent to the native component.
|
|
40
76
|
* Does not include the `onPress` callback — callbacks are managed on the JS side.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/types/events.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,2CAA2C;IAC3C,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAChD;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/types/events.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,2CAA2C;IAC3C,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAChD;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,kFAAkF;IAClF,MAAM,EAAE,OAAO,CAAC;IAChB,uEAAuE;IACvE,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC5B,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,aAAa,CAAC;IACpB,+DAA+D;IAC/D,SAAS,EAAE,aAAa,CAAC;IACzB,8DAA8D;IAC9D,OAAO,EAAE,aAAa,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { EnrichedMarkdownTextProps } from '../types/MarkdownTextProps.web';
|
|
2
|
-
export declare const EnrichedMarkdownText: ({ markdown, markdownStyle, md4cFlags, onLinkPress, onLinkLongPress, onTaskListItemPress, enableTaskListItemToggle, allowTrailingMargin, containerStyle, selectable, dir, selectionColor, ...rest }: EnrichedMarkdownTextProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
2
|
+
export declare const EnrichedMarkdownText: ({ markdown, markdownStyle, md4cFlags, onLinkPress, onLinkLongPress, onTaskListItemPress, enableTaskListItemToggle, allowTrailingMargin, containerStyle, selectable, dir, selectionColor, renderLinkDecoration, ...rest }: EnrichedMarkdownTextProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
3
3
|
export default EnrichedMarkdownText;
|
|
4
4
|
//# sourceMappingURL=EnrichedMarkdownText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnrichedMarkdownText.d.ts","sourceRoot":"","sources":["../../../../src/web/EnrichedMarkdownText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAehF,eAAO,MAAM,oBAAoB,GAAI,
|
|
1
|
+
{"version":3,"file":"EnrichedMarkdownText.d.ts","sourceRoot":"","sources":["../../../../src/web/EnrichedMarkdownText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAehF,eAAO,MAAM,oBAAoB,GAAI,0NAelC,yBAAyB,mDA6I3B,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineRenderers.d.ts","sourceRoot":"","sources":["../../../../../src/web/renderers/InlineRenderers.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InlineRenderers.d.ts","sourceRoot":"","sources":["../../../../../src/web/renderers/InlineRenderers.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAiB,WAAW,EAAE,MAAM,UAAU,CAAC;AAmN3D,eAAO,MAAM,eAAe,EAAE,WAc7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/web/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AAwCxC,wBAAgB,mBAAmB,CACjC,KAAK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actNode } from 'react';
|
|
|
2
2
|
import type { MarkdownStyleInternal } from '../types/MarkdownStyleInternal';
|
|
3
3
|
import type { Styles } from './styles';
|
|
4
4
|
import type { LinkPressEvent, LinkLongPressEvent, TaskListItemPressEvent } from '../types/events';
|
|
5
|
+
import type { LinkDecorationInfo } from '../types/MarkdownTextProps.web';
|
|
5
6
|
import type { KaTeXInstance } from './katex';
|
|
6
7
|
export type NodeType = 'Document' | 'Paragraph' | 'Text' | 'Link' | 'Heading' | 'LineBreak' | 'SoftBreak' | 'Strong' | 'Emphasis' | 'Strikethrough' | 'Underline' | 'Superscript' | 'Subscript' | 'Highlight' | 'Code' | 'Image' | 'Blockquote' | 'UnorderedList' | 'OrderedList' | 'ListItem' | 'CodeBlock' | 'ThematicBreak' | 'Table' | 'TableHead' | 'TableBody' | 'TableRow' | 'TableHeaderCell' | 'TableCell' | 'LatexMathInline' | 'LatexMathDisplay';
|
|
7
8
|
export interface NodeAttributes {
|
|
@@ -16,6 +17,8 @@ export interface NodeAttributes {
|
|
|
16
17
|
taskIndex?: number;
|
|
17
18
|
/** Stamped by markInlineImages() — not present in the raw WASM output. */
|
|
18
19
|
isInline?: boolean;
|
|
20
|
+
/** Stamped by indexLinks() — document-order link index, not in the raw WASM output. */
|
|
21
|
+
linkIndex?: number;
|
|
19
22
|
colCount?: string;
|
|
20
23
|
headRowCount?: string;
|
|
21
24
|
bodyRowCount?: string;
|
|
@@ -34,6 +37,7 @@ export interface RendererCallbacks {
|
|
|
34
37
|
onLinkPress?: (event: LinkPressEvent) => void;
|
|
35
38
|
onLinkLongPress?: (event: LinkLongPressEvent) => void;
|
|
36
39
|
onTaskListItemPress?: (event: TaskListItemPressEvent) => void;
|
|
40
|
+
renderLinkDecoration?: (info: LinkDecorationInfo) => ReactNode | null;
|
|
37
41
|
}
|
|
38
42
|
export interface RenderCapabilities {
|
|
39
43
|
katex: KaTeXInstance | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","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AE,kBAAkB,KAAK,SAAS,GAAG,IAAI,CAAC;CACvE;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5B,2EAA2E;IAC3E,wBAAwB,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,qBAAqB,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,QAAQ,CAAC;IACtB,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,iBAAiB,CAAC;IAC7B,YAAY,EAAE,kBAAkB,CAAC;IACjC,cAAc,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,SAAS,CAAC;CAC9C;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,CAC/B,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,aAAa,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
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
codegenNativeComponent,
|
|
3
|
+
codegenNativeCommands,
|
|
3
4
|
type ViewProps,
|
|
4
5
|
type CodegenTypes,
|
|
5
6
|
type ColorValue,
|
|
7
|
+
type HostComponent,
|
|
6
8
|
} from 'react-native';
|
|
9
|
+
import type React from 'react';
|
|
7
10
|
|
|
8
11
|
// All block styles extend this interface
|
|
9
12
|
interface BaseBlockStyleInternal {
|
|
@@ -75,6 +78,11 @@ interface LinkStyleInternal {
|
|
|
75
78
|
color: ColorValue;
|
|
76
79
|
underline: boolean;
|
|
77
80
|
backgroundColor: ColorValue;
|
|
81
|
+
borderRadius: CodegenTypes.Float;
|
|
82
|
+
paddingHorizontal: CodegenTypes.Float;
|
|
83
|
+
paddingVertical: CodegenTypes.Float;
|
|
84
|
+
borderColor: ColorValue;
|
|
85
|
+
borderWidth: CodegenTypes.Float;
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
// Mirrors EnrichedMarkdownTextNativeComponent.ts — kept in sync manually (codegen spec files must be self-contained).
|
|
@@ -83,6 +91,11 @@ interface LinkVariantEntryInternal {
|
|
|
83
91
|
color: ColorValue;
|
|
84
92
|
underline: boolean;
|
|
85
93
|
backgroundColor: ColorValue;
|
|
94
|
+
borderRadius: CodegenTypes.Float;
|
|
95
|
+
paddingHorizontal: CodegenTypes.Float;
|
|
96
|
+
paddingVertical: CodegenTypes.Float;
|
|
97
|
+
borderColor: ColorValue;
|
|
98
|
+
borderWidth: CodegenTypes.Float;
|
|
86
99
|
}
|
|
87
100
|
|
|
88
101
|
interface StrongStyleInternal {
|
|
@@ -245,6 +258,58 @@ export interface LinkLongPressEvent {
|
|
|
245
258
|
url: string;
|
|
246
259
|
}
|
|
247
260
|
|
|
261
|
+
/**
|
|
262
|
+
* `fragments` holds one entry per laid-out line of a link (a wrapping link
|
|
263
|
+
* yields several). Rects are in dp, relative to the native view's origin, and
|
|
264
|
+
* cover the drawn chip (glyphs + padding). Flattened rather than nested per
|
|
265
|
+
* link, and written inline, because codegen only accepts inline object
|
|
266
|
+
* literals as event array elements.
|
|
267
|
+
*/
|
|
268
|
+
export interface LinkLayoutEvent {
|
|
269
|
+
fragments: {
|
|
270
|
+
linkIndex: CodegenTypes.Int32;
|
|
271
|
+
url: string;
|
|
272
|
+
text: string;
|
|
273
|
+
x: CodegenTypes.Double;
|
|
274
|
+
y: CodegenTypes.Double;
|
|
275
|
+
width: CodegenTypes.Double;
|
|
276
|
+
height: CodegenTypes.Double;
|
|
277
|
+
}[];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Current text selection, or a long-pressed table / math / code block while
|
|
282
|
+
* `contextMenuHidden` is on. `active: false` means the selection was cleared
|
|
283
|
+
* (every other field is then empty / zero). Rects are in dp / pt, relative to
|
|
284
|
+
* the native view's origin; rect objects are written inline because codegen
|
|
285
|
+
* only accepts inline object literals in event payloads.
|
|
286
|
+
*/
|
|
287
|
+
export interface SelectionChangeEvent {
|
|
288
|
+
active: boolean;
|
|
289
|
+
source: string;
|
|
290
|
+
text: string;
|
|
291
|
+
markdown: string;
|
|
292
|
+
whole: boolean;
|
|
293
|
+
rect: {
|
|
294
|
+
x: CodegenTypes.Double;
|
|
295
|
+
y: CodegenTypes.Double;
|
|
296
|
+
width: CodegenTypes.Double;
|
|
297
|
+
height: CodegenTypes.Double;
|
|
298
|
+
};
|
|
299
|
+
startRect: {
|
|
300
|
+
x: CodegenTypes.Double;
|
|
301
|
+
y: CodegenTypes.Double;
|
|
302
|
+
width: CodegenTypes.Double;
|
|
303
|
+
height: CodegenTypes.Double;
|
|
304
|
+
};
|
|
305
|
+
endRect: {
|
|
306
|
+
x: CodegenTypes.Double;
|
|
307
|
+
y: CodegenTypes.Double;
|
|
308
|
+
width: CodegenTypes.Double;
|
|
309
|
+
height: CodegenTypes.Double;
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
248
313
|
export interface TaskListItemPressEvent {
|
|
249
314
|
index: CodegenTypes.Int32;
|
|
250
315
|
checked: boolean;
|
|
@@ -400,6 +465,30 @@ export interface NativeProps extends ViewProps {
|
|
|
400
465
|
* - Android: Handles long press gestures on links.
|
|
401
466
|
*/
|
|
402
467
|
onLinkLongPress?: CodegenTypes.BubblingEventHandler<LinkLongPressEvent>;
|
|
468
|
+
/**
|
|
469
|
+
* When true, the view reports the laid-out rects of every link through
|
|
470
|
+
* `onLinkLayout` (after each render and whenever its size changes).
|
|
471
|
+
* Set by the JS wrapper only when `renderLinkDecoration` is provided.
|
|
472
|
+
* @default false
|
|
473
|
+
*/
|
|
474
|
+
emitLinkLayout?: CodegenTypes.WithDefault<boolean, false>;
|
|
475
|
+
/**
|
|
476
|
+
* Fired with the rects of every link fragment while `emitLinkLayout` is on.
|
|
477
|
+
* Deduplicated: not re-fired when the payload is unchanged.
|
|
478
|
+
*/
|
|
479
|
+
onLinkLayout?: CodegenTypes.DirectEventHandler<LinkLayoutEvent>;
|
|
480
|
+
/**
|
|
481
|
+
* When true, the view reports selection changes (and, with
|
|
482
|
+
* `contextMenuHidden`, block long-presses) through `onSelectionChange`.
|
|
483
|
+
* Set by the JS wrapper only when `onSelectionChange` is provided.
|
|
484
|
+
* @default false
|
|
485
|
+
*/
|
|
486
|
+
emitSelectionChange?: CodegenTypes.WithDefault<boolean, false>;
|
|
487
|
+
/**
|
|
488
|
+
* Fired while `emitSelectionChange` is on: coalesced to one event per frame,
|
|
489
|
+
* deduplicated, and `active: false` once the selection is gone.
|
|
490
|
+
*/
|
|
491
|
+
onSelectionChange?: CodegenTypes.DirectEventHandler<SelectionChangeEvent>;
|
|
403
492
|
/**
|
|
404
493
|
* Callback fired when a task list checkbox is tapped.
|
|
405
494
|
* Receives the 0-based task index, current checked state, and the item's plain text.
|
|
@@ -553,6 +642,17 @@ export interface NativeProps extends ViewProps {
|
|
|
553
642
|
writingDirection?: CodegenTypes.WithDefault<string, 'first-strong'>;
|
|
554
643
|
}
|
|
555
644
|
|
|
645
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
646
|
+
|
|
647
|
+
interface NativeCommands {
|
|
648
|
+
/** Clears the text selection (and any active block) and fires `onSelectionChange` with `active: false`. */
|
|
649
|
+
clearSelection: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
653
|
+
supportedCommands: ['clearSelection'],
|
|
654
|
+
});
|
|
655
|
+
|
|
556
656
|
export default codegenNativeComponent<NativeProps>('EnrichedMarkdown', {
|
|
557
657
|
interfaceOnly: true,
|
|
558
|
-
})
|
|
658
|
+
}) as HostComponent<NativeProps>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
codegenNativeComponent,
|
|
3
|
+
codegenNativeCommands,
|
|
3
4
|
type ViewProps,
|
|
4
5
|
type CodegenTypes,
|
|
5
6
|
type ColorValue,
|
|
7
|
+
type HostComponent,
|
|
6
8
|
} from 'react-native';
|
|
9
|
+
import type React from 'react';
|
|
7
10
|
|
|
8
11
|
// All block styles extend this interface
|
|
9
12
|
interface BaseBlockStyleInternal {
|
|
@@ -75,6 +78,11 @@ interface LinkStyleInternal {
|
|
|
75
78
|
color: ColorValue;
|
|
76
79
|
underline: boolean;
|
|
77
80
|
backgroundColor: ColorValue;
|
|
81
|
+
borderRadius: CodegenTypes.Float;
|
|
82
|
+
paddingHorizontal: CodegenTypes.Float;
|
|
83
|
+
paddingVertical: CodegenTypes.Float;
|
|
84
|
+
borderColor: ColorValue;
|
|
85
|
+
borderWidth: CodegenTypes.Float;
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
// Mirrors EnrichedMarkdownNativeComponent.ts — kept in sync manually (codegen spec files must be self-contained).
|
|
@@ -83,6 +91,11 @@ interface LinkVariantEntryInternal {
|
|
|
83
91
|
color: ColorValue;
|
|
84
92
|
underline: boolean;
|
|
85
93
|
backgroundColor: ColorValue;
|
|
94
|
+
borderRadius: CodegenTypes.Float;
|
|
95
|
+
paddingHorizontal: CodegenTypes.Float;
|
|
96
|
+
paddingVertical: CodegenTypes.Float;
|
|
97
|
+
borderColor: ColorValue;
|
|
98
|
+
borderWidth: CodegenTypes.Float;
|
|
86
99
|
}
|
|
87
100
|
|
|
88
101
|
interface StrongStyleInternal {
|
|
@@ -246,6 +259,58 @@ export interface LinkLongPressEvent {
|
|
|
246
259
|
url: string;
|
|
247
260
|
}
|
|
248
261
|
|
|
262
|
+
/**
|
|
263
|
+
* `fragments` holds one entry per laid-out line of a link (a wrapping link
|
|
264
|
+
* yields several). Rects are in dp, relative to the native view's origin, and
|
|
265
|
+
* cover the drawn chip (glyphs + padding). Flattened rather than nested per
|
|
266
|
+
* link, and written inline, because codegen only accepts inline object
|
|
267
|
+
* literals as event array elements.
|
|
268
|
+
*/
|
|
269
|
+
export interface LinkLayoutEvent {
|
|
270
|
+
fragments: {
|
|
271
|
+
linkIndex: CodegenTypes.Int32;
|
|
272
|
+
url: string;
|
|
273
|
+
text: string;
|
|
274
|
+
x: CodegenTypes.Double;
|
|
275
|
+
y: CodegenTypes.Double;
|
|
276
|
+
width: CodegenTypes.Double;
|
|
277
|
+
height: CodegenTypes.Double;
|
|
278
|
+
}[];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Current text selection, or a long-pressed table / math / code block while
|
|
283
|
+
* `contextMenuHidden` is on. `active: false` means the selection was cleared
|
|
284
|
+
* (every other field is then empty / zero). Rects are in dp / pt, relative to
|
|
285
|
+
* the native view's origin; rect objects are written inline because codegen
|
|
286
|
+
* only accepts inline object literals in event payloads.
|
|
287
|
+
*/
|
|
288
|
+
export interface SelectionChangeEvent {
|
|
289
|
+
active: boolean;
|
|
290
|
+
source: string;
|
|
291
|
+
text: string;
|
|
292
|
+
markdown: string;
|
|
293
|
+
whole: boolean;
|
|
294
|
+
rect: {
|
|
295
|
+
x: CodegenTypes.Double;
|
|
296
|
+
y: CodegenTypes.Double;
|
|
297
|
+
width: CodegenTypes.Double;
|
|
298
|
+
height: CodegenTypes.Double;
|
|
299
|
+
};
|
|
300
|
+
startRect: {
|
|
301
|
+
x: CodegenTypes.Double;
|
|
302
|
+
y: CodegenTypes.Double;
|
|
303
|
+
width: CodegenTypes.Double;
|
|
304
|
+
height: CodegenTypes.Double;
|
|
305
|
+
};
|
|
306
|
+
endRect: {
|
|
307
|
+
x: CodegenTypes.Double;
|
|
308
|
+
y: CodegenTypes.Double;
|
|
309
|
+
width: CodegenTypes.Double;
|
|
310
|
+
height: CodegenTypes.Double;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
249
314
|
export interface TaskListItemPressEvent {
|
|
250
315
|
index: CodegenTypes.Int32;
|
|
251
316
|
checked: boolean;
|
|
@@ -401,6 +466,30 @@ export interface NativeProps extends ViewProps {
|
|
|
401
466
|
* - Android: Handles long press gestures on links.
|
|
402
467
|
*/
|
|
403
468
|
onLinkLongPress?: CodegenTypes.BubblingEventHandler<LinkLongPressEvent>;
|
|
469
|
+
/**
|
|
470
|
+
* When true, the view reports the laid-out rects of every link through
|
|
471
|
+
* `onLinkLayout` (after each render and whenever its size changes).
|
|
472
|
+
* Set by the JS wrapper only when `renderLinkDecoration` is provided.
|
|
473
|
+
* @default false
|
|
474
|
+
*/
|
|
475
|
+
emitLinkLayout?: CodegenTypes.WithDefault<boolean, false>;
|
|
476
|
+
/**
|
|
477
|
+
* Fired with the rects of every link fragment while `emitLinkLayout` is on.
|
|
478
|
+
* Deduplicated: not re-fired when the payload is unchanged.
|
|
479
|
+
*/
|
|
480
|
+
onLinkLayout?: CodegenTypes.DirectEventHandler<LinkLayoutEvent>;
|
|
481
|
+
/**
|
|
482
|
+
* When true, the view reports selection changes (and, with
|
|
483
|
+
* `contextMenuHidden`, block long-presses) through `onSelectionChange`.
|
|
484
|
+
* Set by the JS wrapper only when `onSelectionChange` is provided.
|
|
485
|
+
* @default false
|
|
486
|
+
*/
|
|
487
|
+
emitSelectionChange?: CodegenTypes.WithDefault<boolean, false>;
|
|
488
|
+
/**
|
|
489
|
+
* Fired while `emitSelectionChange` is on: coalesced to one event per frame,
|
|
490
|
+
* deduplicated, and `active: false` once the selection is gone.
|
|
491
|
+
*/
|
|
492
|
+
onSelectionChange?: CodegenTypes.DirectEventHandler<SelectionChangeEvent>;
|
|
404
493
|
/**
|
|
405
494
|
* Callback fired when a task list checkbox is tapped.
|
|
406
495
|
* Receives the 0-based task index, current checked state, and the item's plain text.
|
|
@@ -553,6 +642,17 @@ export interface NativeProps extends ViewProps {
|
|
|
553
642
|
writingDirection?: CodegenTypes.WithDefault<string, 'first-strong'>;
|
|
554
643
|
}
|
|
555
644
|
|
|
645
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
646
|
+
|
|
647
|
+
interface NativeCommands {
|
|
648
|
+
/** Clears the text selection (and any active block) and fires `onSelectionChange` with `active: false`. */
|
|
649
|
+
clearSelection: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
653
|
+
supportedCommands: ['clearSelection'],
|
|
654
|
+
});
|
|
655
|
+
|
|
556
656
|
export default codegenNativeComponent<NativeProps>('EnrichedMarkdownText', {
|
|
557
657
|
interfaceOnly: true,
|
|
558
|
-
})
|
|
658
|
+
}) as HostComponent<NativeProps>;
|
package/src/index.tsx
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
export { default as EnrichedMarkdownText } from './native/EnrichedMarkdownText';
|
|
2
2
|
export type {
|
|
3
3
|
EnrichedMarkdownTextProps,
|
|
4
|
+
EnrichedMarkdownTextInstance,
|
|
4
5
|
StreamingConfig,
|
|
5
6
|
MarkdownStyle,
|
|
6
7
|
Md4cFlags,
|
|
7
8
|
ContextMenuItem as TextContextMenuItem,
|
|
8
9
|
SelectionMenuConfig as TextSelectionMenuConfig,
|
|
9
10
|
SelectionMenuPluralLabels as TextSelectionMenuPluralLabels,
|
|
11
|
+
LinkDecorationInfo,
|
|
12
|
+
LinkRect,
|
|
10
13
|
} from './native/EnrichedMarkdownText';
|
|
11
14
|
export type {
|
|
12
15
|
LinkPressEvent,
|
|
@@ -15,6 +18,8 @@ export type {
|
|
|
15
18
|
CopyPressEvent,
|
|
16
19
|
CopyEvent,
|
|
17
20
|
OnPasteEvent,
|
|
21
|
+
SelectionChangeEvent,
|
|
22
|
+
SelectionRect,
|
|
18
23
|
} from './types/events';
|
|
19
24
|
export type {
|
|
20
25
|
AccessibilityLabels,
|