react-native-enriched-markdown-scaffold 1.0.2-scaffold.1 → 1.0.2-scaffold.3
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/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +24 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +18 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +60 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +31 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/CopyRequestEvent.kt +28 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +23 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionActionMode.kt +50 -13
- package/android/src/main/java/com/swmansion/enriched/markdown/views/BlockMenuOptions.kt +64 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/CodeBlockContainerView.kt +19 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/views/TableContainerView.kt +7 -5
- package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +6 -4
- package/docs/API_REFERENCE.md +60 -4
- package/docs/COPY_OPTIONS.md +40 -0
- package/ios/EnrichedMarkdown.mm +63 -8
- package/ios/EnrichedMarkdownText.mm +26 -5
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +24 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +18 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +60 -0
- package/ios/utils/ENRMBlockMenu.h +66 -0
- package/ios/utils/EditMenuUtils.h +32 -6
- package/ios/utils/EditMenuUtils.m +51 -14
- package/ios/views/ENRMCodeBlockContainerView.h +13 -2
- package/ios/views/ENRMCodeBlockContainerView.m +19 -19
- package/ios/views/ENRMMathContainerView.h +8 -0
- package/ios/views/ENRMMathContainerView.m +10 -18
- package/ios/views/TableContainerView.h +8 -0
- package/ios/views/TableContainerView.m +10 -18
- package/lib/module/EnrichedMarkdownNativeComponent.ts +24 -0
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +24 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/native/EnrichedMarkdownText.js +29 -2
- package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +17 -0
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +17 -0
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +3 -3
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.d.ts +53 -10
- package/lib/typescript/src/types/MarkdownTextProps.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/package.json +1 -1
- package/src/EnrichedMarkdownNativeComponent.ts +24 -0
- package/src/EnrichedMarkdownTextNativeComponent.ts +24 -0
- package/src/index.tsx +1 -0
- package/src/native/EnrichedMarkdownText.tsx +37 -1
- package/src/types/MarkdownTextProps.ts +50 -10
- package/src/types/events.ts +23 -0
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
LinkLongPressEvent,
|
|
7
7
|
TaskListItemPressEvent,
|
|
8
8
|
CopyPressEvent,
|
|
9
|
+
CopyEvent,
|
|
9
10
|
} from './events';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -57,22 +58,31 @@ export interface SelectionMenuPluralLabels {
|
|
|
57
58
|
* Controls the built-in items added to the native text selection menu and
|
|
58
59
|
* lets you localize their labels.
|
|
59
60
|
*
|
|
60
|
-
* Each item accepts an object: `{ enabled }` toggles visibility
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
61
|
+
* Each item accepts an object: `{ enabled }` toggles visibility and `label`
|
|
62
|
+
* overrides the English default. Wire `label` to your i18n library to match
|
|
63
|
+
* the rest of your app's UI. Items and labels apply to the main text selection
|
|
64
|
+
* menu as well as the table, math and code block copy menus.
|
|
65
|
+
*
|
|
66
|
+
* `copy.enabled`, `copy.format` and `systemItems` are ignored on macOS.
|
|
65
67
|
*
|
|
66
68
|
* @platform ios, android, macos
|
|
67
69
|
*/
|
|
68
70
|
export interface SelectionMenuConfig {
|
|
69
71
|
/**
|
|
70
|
-
* The
|
|
71
|
-
*
|
|
72
|
+
* The "Copy" item.
|
|
73
|
+
* - `enabled`: `false` removes it from the text selection menu, the table /
|
|
74
|
+
* math / code block menus and the code block VoiceOver copy action.
|
|
75
|
+
* - `format`: `'rich'` copies rich text (plain + HTML, plus RTF on iOS) from
|
|
76
|
+
* text selections and the raw content from blocks; `'markdown'` copies
|
|
77
|
+
* Markdown as plain text everywhere the item appears (inline math becomes
|
|
78
|
+
* `$…$`, math blocks `$$…$$`, code blocks are fenced). The code block header
|
|
79
|
+
* button and VoiceOver action always copy the raw code.
|
|
80
|
+
* @default { enabled: true, label: "Copy", format: "rich" }
|
|
72
81
|
*/
|
|
73
|
-
copy?: { label?: string };
|
|
82
|
+
copy?: { enabled?: boolean; label?: string; format?: 'rich' | 'markdown' };
|
|
74
83
|
/**
|
|
75
|
-
* The built-in "Copy as Markdown" action
|
|
84
|
+
* The built-in "Copy as Markdown" action, in the text selection menu and in
|
|
85
|
+
* the table / math / code block menus.
|
|
76
86
|
* @default { enabled: true, label: "Copy as Markdown" }
|
|
77
87
|
*/
|
|
78
88
|
copyAsMarkdown?: { enabled?: boolean; label?: string };
|
|
@@ -87,6 +97,23 @@ export interface SelectionMenuConfig {
|
|
|
87
97
|
label?: string;
|
|
88
98
|
pluralLabels?: SelectionMenuPluralLabels;
|
|
89
99
|
};
|
|
100
|
+
/**
|
|
101
|
+
* Which system items the text selection menu keeps.
|
|
102
|
+
* - `'default'`: keep everything the OS adds (Select All, Look Up, Share,
|
|
103
|
+
* Translate, app text actions…), with Copy replaced by the built-in one.
|
|
104
|
+
* - `'none'`: drop every system item; the menu only holds the built-in items
|
|
105
|
+
* above and `contextMenuItems`.
|
|
106
|
+
* @default 'default'
|
|
107
|
+
* @platform ios, android
|
|
108
|
+
*/
|
|
109
|
+
systemItems?: 'default' | 'none';
|
|
110
|
+
/**
|
|
111
|
+
* The copy button in the code block header. `false` hides the button; the
|
|
112
|
+
* header and language label stay.
|
|
113
|
+
* @default { enabled: true }
|
|
114
|
+
* @platform ios, android, macos
|
|
115
|
+
*/
|
|
116
|
+
codeBlockCopyButton?: { enabled?: boolean };
|
|
90
117
|
}
|
|
91
118
|
|
|
92
119
|
export interface StreamingConfig {
|
|
@@ -179,13 +206,26 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
|
|
|
179
206
|
* Callback fired when code is copied from a fenced code block, via the header
|
|
180
207
|
* copy button, the long-press context-menu "Copy" action, or the VoiceOver
|
|
181
208
|
* copy action. Receives the copied code and its language. Does not fire for
|
|
182
|
-
* "Copy as Markdown"
|
|
209
|
+
* "Copy as Markdown", nor for the context-menu "Copy" when
|
|
210
|
+
* `selectionMenuConfig.copy.format` is `'markdown'`.
|
|
183
211
|
*
|
|
184
212
|
* Only fires when `flavor="github"` (the copy button is part of the GitHub
|
|
185
213
|
* flavor's container-based code block renderer).
|
|
186
214
|
* @platform ios, android, macos
|
|
187
215
|
*/
|
|
188
216
|
onCopyPress?: (event: CopyPressEvent) => void;
|
|
217
|
+
/**
|
|
218
|
+
* Takes over the "Copy" item of the text selection menu and of the table /
|
|
219
|
+
* math / code block menus. When set, native does **not** write the
|
|
220
|
+
* clipboard: it calls this with the copied content and the handler writes
|
|
221
|
+
* whatever it wants (e.g. with `expo-clipboard`). Overrides
|
|
222
|
+
* `selectionMenuConfig.copy.format`; `copy.enabled: false` still hides the
|
|
223
|
+
* item. "Copy as Markdown", the code block header button and the VoiceOver
|
|
224
|
+
* copy action are unaffected, and `onCopyPress` does not fire for an
|
|
225
|
+
* intercepted Copy.
|
|
226
|
+
* @platform ios, android
|
|
227
|
+
*/
|
|
228
|
+
onCopy?: (event: CopyEvent) => void;
|
|
189
229
|
/**
|
|
190
230
|
* Controls whether the system link preview is shown on long press (iOS only).
|
|
191
231
|
*
|
package/src/types/events.ts
CHANGED
|
@@ -17,6 +17,29 @@ export interface CopyPressEvent {
|
|
|
17
17
|
language: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Payload of `onCopy`: what the Copy item would have copied. With `onCopy`
|
|
22
|
+
* set, native writes nothing to the clipboard — the handler owns the write.
|
|
23
|
+
*/
|
|
24
|
+
export interface CopyEvent {
|
|
25
|
+
/** Which menu the Copy item belongs to. */
|
|
26
|
+
source: 'selection' | 'math' | 'table' | 'code';
|
|
27
|
+
/**
|
|
28
|
+
* Markdown of the copied content — what `copy.format: 'markdown'` writes.
|
|
29
|
+
* Text selections: the original source when `whole`, otherwise rebuilt from
|
|
30
|
+
* the rendered styles (falls back to `text`). Blocks: `$$…$$`, the table as
|
|
31
|
+
* Markdown, or the fenced code block.
|
|
32
|
+
*/
|
|
33
|
+
markdown: string;
|
|
34
|
+
/** Rendered text of the selection, or the block's raw content. */
|
|
35
|
+
text: string;
|
|
36
|
+
/**
|
|
37
|
+
* `true` when the selection covers the whole component, so `markdown` is the
|
|
38
|
+
* original source. Always `true` for blocks.
|
|
39
|
+
*/
|
|
40
|
+
whole: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
20
43
|
/**
|
|
21
44
|
* Native-level context menu item config sent to the native component.
|
|
22
45
|
* Does not include the `onPress` callback — callbacks are managed on the JS side.
|