@domenico-esposito/react-native-markdown-editor 0.1.1
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/.eslintrc.js +5 -0
- package/README.md +265 -0
- package/build/MarkdownRenderer.d.ts +12 -0
- package/build/MarkdownRenderer.d.ts.map +1 -0
- package/build/MarkdownRenderer.js +165 -0
- package/build/MarkdownRenderer.js.map +1 -0
- package/build/MarkdownTextInput.d.ts +10 -0
- package/build/MarkdownTextInput.d.ts.map +1 -0
- package/build/MarkdownTextInput.js +233 -0
- package/build/MarkdownTextInput.js.map +1 -0
- package/build/MarkdownToolbar.d.ts +11 -0
- package/build/MarkdownToolbar.d.ts.map +1 -0
- package/build/MarkdownToolbar.js +98 -0
- package/build/MarkdownToolbar.js.map +1 -0
- package/build/index.d.ts +14 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +11 -0
- package/build/index.js.map +1 -0
- package/build/markdownCore.types.d.ts +321 -0
- package/build/markdownCore.types.d.ts.map +1 -0
- package/build/markdownCore.types.js +2 -0
- package/build/markdownCore.types.js.map +1 -0
- package/build/markdownHighlight.d.ts +31 -0
- package/build/markdownHighlight.d.ts.map +1 -0
- package/build/markdownHighlight.js +378 -0
- package/build/markdownHighlight.js.map +1 -0
- package/build/markdownHighlight.types.d.ts +48 -0
- package/build/markdownHighlight.types.d.ts.map +1 -0
- package/build/markdownHighlight.types.js +9 -0
- package/build/markdownHighlight.types.js.map +1 -0
- package/build/markdownParser.d.ts +16 -0
- package/build/markdownParser.d.ts.map +1 -0
- package/build/markdownParser.js +309 -0
- package/build/markdownParser.js.map +1 -0
- package/build/markdownRendererDefaults.d.ts +113 -0
- package/build/markdownRendererDefaults.d.ts.map +1 -0
- package/build/markdownRendererDefaults.js +174 -0
- package/build/markdownRendererDefaults.js.map +1 -0
- package/build/markdownSegment.types.d.ts +22 -0
- package/build/markdownSegment.types.d.ts.map +1 -0
- package/build/markdownSegment.types.js +2 -0
- package/build/markdownSegment.types.js.map +1 -0
- package/build/markdownSegmentDefaults.d.ts +43 -0
- package/build/markdownSegmentDefaults.d.ts.map +1 -0
- package/build/markdownSegmentDefaults.js +176 -0
- package/build/markdownSegmentDefaults.js.map +1 -0
- package/build/markdownSyntaxUtils.d.ts +58 -0
- package/build/markdownSyntaxUtils.d.ts.map +1 -0
- package/build/markdownSyntaxUtils.js +98 -0
- package/build/markdownSyntaxUtils.js.map +1 -0
- package/build/markdownToolbarActions.d.ts +12 -0
- package/build/markdownToolbarActions.d.ts.map +1 -0
- package/build/markdownToolbarActions.js +212 -0
- package/build/markdownToolbarActions.js.map +1 -0
- package/build/useMarkdownEditor.d.ts +10 -0
- package/build/useMarkdownEditor.d.ts.map +1 -0
- package/build/useMarkdownEditor.js +219 -0
- package/build/useMarkdownEditor.js.map +1 -0
- package/jest.config.js +10 -0
- package/package.json +45 -0
- package/src/MarkdownRenderer.tsx +240 -0
- package/src/MarkdownTextInput.tsx +263 -0
- package/src/MarkdownToolbar.tsx +126 -0
- package/src/index.ts +31 -0
- package/src/markdownCore.types.ts +405 -0
- package/src/markdownHighlight.ts +413 -0
- package/src/markdownHighlight.types.ts +75 -0
- package/src/markdownParser.ts +345 -0
- package/src/markdownRendererDefaults.tsx +207 -0
- package/src/markdownSegment.types.ts +24 -0
- package/src/markdownSegmentDefaults.tsx +208 -0
- package/src/markdownSyntaxUtils.ts +139 -0
- package/src/markdownToolbarActions.ts +296 -0
- package/src/useMarkdownEditor.ts +265 -0
- package/tsconfig.json +9 -0
- package/tsconfig.test.json +8 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
3
|
+
import type { StyleProp, TextInputProps, TextStyle, ViewStyle } from 'react-native';
|
|
4
|
+
import type { HighlightSegment } from './markdownHighlight.types';
|
|
5
|
+
import type { SegmentComponentMap } from './markdownSegment.types';
|
|
6
|
+
export type MarkdownTextNode = {
|
|
7
|
+
type: 'text';
|
|
8
|
+
content: string;
|
|
9
|
+
};
|
|
10
|
+
export type MarkdownBoldNode = {
|
|
11
|
+
type: 'bold';
|
|
12
|
+
children: MarkdownInlineNode[];
|
|
13
|
+
};
|
|
14
|
+
export type MarkdownItalicNode = {
|
|
15
|
+
type: 'italic';
|
|
16
|
+
children: MarkdownInlineNode[];
|
|
17
|
+
};
|
|
18
|
+
export type MarkdownInlineCodeNode = {
|
|
19
|
+
type: 'code';
|
|
20
|
+
content: string;
|
|
21
|
+
};
|
|
22
|
+
export type MarkdownLinkNode = {
|
|
23
|
+
type: 'link';
|
|
24
|
+
href: string;
|
|
25
|
+
children: MarkdownInlineNode[];
|
|
26
|
+
};
|
|
27
|
+
export type MarkdownStrikethroughNode = {
|
|
28
|
+
type: 'strikethrough';
|
|
29
|
+
children: MarkdownInlineNode[];
|
|
30
|
+
};
|
|
31
|
+
export type MarkdownImageNode = {
|
|
32
|
+
type: 'image';
|
|
33
|
+
src: string;
|
|
34
|
+
alt: string;
|
|
35
|
+
title?: string;
|
|
36
|
+
};
|
|
37
|
+
export type MarkdownInlineNode = MarkdownTextNode | MarkdownBoldNode | MarkdownItalicNode | MarkdownStrikethroughNode | MarkdownInlineCodeNode | MarkdownLinkNode | MarkdownImageNode;
|
|
38
|
+
export type MarkdownParagraphNode = {
|
|
39
|
+
type: 'paragraph';
|
|
40
|
+
children: MarkdownInlineNode[];
|
|
41
|
+
};
|
|
42
|
+
export type MarkdownHeadingNode = {
|
|
43
|
+
type: 'heading';
|
|
44
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
45
|
+
children: MarkdownInlineNode[];
|
|
46
|
+
};
|
|
47
|
+
export type MarkdownCodeBlockNode = {
|
|
48
|
+
type: 'codeBlock';
|
|
49
|
+
language?: string;
|
|
50
|
+
content: string;
|
|
51
|
+
};
|
|
52
|
+
export type MarkdownBlockquoteNode = {
|
|
53
|
+
type: 'blockquote';
|
|
54
|
+
children: MarkdownInlineNode[];
|
|
55
|
+
};
|
|
56
|
+
export type MarkdownHorizontalRuleNode = {
|
|
57
|
+
type: 'horizontalRule';
|
|
58
|
+
};
|
|
59
|
+
export type MarkdownSpacerNode = {
|
|
60
|
+
type: 'spacer';
|
|
61
|
+
};
|
|
62
|
+
export type MarkdownListNode = {
|
|
63
|
+
type: 'list';
|
|
64
|
+
ordered: boolean;
|
|
65
|
+
items: MarkdownInlineNode[][];
|
|
66
|
+
};
|
|
67
|
+
export type MarkdownListItemNode = {
|
|
68
|
+
type: 'listItem';
|
|
69
|
+
ordered: boolean;
|
|
70
|
+
index: number;
|
|
71
|
+
children: MarkdownInlineNode[];
|
|
72
|
+
};
|
|
73
|
+
export type MarkdownBlockNode = MarkdownParagraphNode | MarkdownHeadingNode | MarkdownCodeBlockNode | MarkdownBlockquoteNode | MarkdownHorizontalRuleNode | MarkdownSpacerNode | MarkdownListNode;
|
|
74
|
+
export type MarkdownRootNode = {
|
|
75
|
+
type: 'root';
|
|
76
|
+
children: MarkdownBlockNode[];
|
|
77
|
+
};
|
|
78
|
+
export type MarkdownNode = MarkdownInlineNode | MarkdownBlockNode | MarkdownListItemNode | MarkdownRootNode;
|
|
79
|
+
export type MarkdownTag = 'root' | 'paragraph' | 'text' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'bold' | 'italic' | 'strikethrough' | 'inlineCode' | 'codeBlock' | 'blockquote' | 'horizontalRule' | 'unorderedList' | 'orderedList' | 'listItem' | 'link' | 'image' | 'spacer';
|
|
80
|
+
/**
|
|
81
|
+
* Common props shared by every custom renderer component.
|
|
82
|
+
* Unlike segment components (editor), renderer components are NOT constrained
|
|
83
|
+
* to Text — they can use View, Image, or any React Native component.
|
|
84
|
+
*/
|
|
85
|
+
export type RendererBaseProps = {
|
|
86
|
+
children?: ReactNode;
|
|
87
|
+
};
|
|
88
|
+
export type RootRendererProps = RendererBaseProps & {
|
|
89
|
+
type: 'root';
|
|
90
|
+
style?: StyleProp<ViewStyle>;
|
|
91
|
+
};
|
|
92
|
+
export type ParagraphRendererProps = RendererBaseProps & {
|
|
93
|
+
type: 'paragraph';
|
|
94
|
+
};
|
|
95
|
+
export type TextRendererProps = RendererBaseProps & {
|
|
96
|
+
type: 'text';
|
|
97
|
+
text: string;
|
|
98
|
+
};
|
|
99
|
+
export type HeadingRendererProps<L extends 1 | 2 | 3 | 4 | 5 | 6> = RendererBaseProps & {
|
|
100
|
+
type: `heading${L}`;
|
|
101
|
+
level: L;
|
|
102
|
+
};
|
|
103
|
+
export type BoldRendererProps = RendererBaseProps & {
|
|
104
|
+
type: 'bold';
|
|
105
|
+
};
|
|
106
|
+
export type ItalicRendererProps = RendererBaseProps & {
|
|
107
|
+
type: 'italic';
|
|
108
|
+
};
|
|
109
|
+
export type StrikethroughRendererProps = RendererBaseProps & {
|
|
110
|
+
type: 'strikethrough';
|
|
111
|
+
};
|
|
112
|
+
export type InlineCodeRendererProps = RendererBaseProps & {
|
|
113
|
+
type: 'inlineCode';
|
|
114
|
+
text: string;
|
|
115
|
+
};
|
|
116
|
+
export type CodeBlockRendererProps = RendererBaseProps & {
|
|
117
|
+
type: 'codeBlock';
|
|
118
|
+
text: string;
|
|
119
|
+
language?: string;
|
|
120
|
+
};
|
|
121
|
+
export type BlockquoteRendererProps = RendererBaseProps & {
|
|
122
|
+
type: 'blockquote';
|
|
123
|
+
};
|
|
124
|
+
export type HorizontalRuleRendererProps = RendererBaseProps & {
|
|
125
|
+
type: 'horizontalRule';
|
|
126
|
+
};
|
|
127
|
+
export type UnorderedListRendererProps = RendererBaseProps & {
|
|
128
|
+
type: 'unorderedList';
|
|
129
|
+
ordered: false;
|
|
130
|
+
};
|
|
131
|
+
export type OrderedListRendererProps = RendererBaseProps & {
|
|
132
|
+
type: 'orderedList';
|
|
133
|
+
ordered: true;
|
|
134
|
+
};
|
|
135
|
+
export type ListItemRendererProps = RendererBaseProps & {
|
|
136
|
+
type: 'listItem';
|
|
137
|
+
ordered: boolean;
|
|
138
|
+
index: number;
|
|
139
|
+
};
|
|
140
|
+
export type LinkRendererProps = RendererBaseProps & {
|
|
141
|
+
type: 'link';
|
|
142
|
+
href: string;
|
|
143
|
+
};
|
|
144
|
+
export type ImageRendererProps = RendererBaseProps & {
|
|
145
|
+
type: 'image';
|
|
146
|
+
src: string;
|
|
147
|
+
alt: string;
|
|
148
|
+
title?: string;
|
|
149
|
+
};
|
|
150
|
+
export type SpacerRendererProps = RendererBaseProps & {
|
|
151
|
+
type: 'spacer';
|
|
152
|
+
};
|
|
153
|
+
export type RendererPropsByTag = {
|
|
154
|
+
root: RootRendererProps;
|
|
155
|
+
paragraph: ParagraphRendererProps;
|
|
156
|
+
text: TextRendererProps;
|
|
157
|
+
heading1: HeadingRendererProps<1>;
|
|
158
|
+
heading2: HeadingRendererProps<2>;
|
|
159
|
+
heading3: HeadingRendererProps<3>;
|
|
160
|
+
heading4: HeadingRendererProps<4>;
|
|
161
|
+
heading5: HeadingRendererProps<5>;
|
|
162
|
+
heading6: HeadingRendererProps<6>;
|
|
163
|
+
bold: BoldRendererProps;
|
|
164
|
+
italic: ItalicRendererProps;
|
|
165
|
+
strikethrough: StrikethroughRendererProps;
|
|
166
|
+
inlineCode: InlineCodeRendererProps;
|
|
167
|
+
codeBlock: CodeBlockRendererProps;
|
|
168
|
+
blockquote: BlockquoteRendererProps;
|
|
169
|
+
horizontalRule: HorizontalRuleRendererProps;
|
|
170
|
+
unorderedList: UnorderedListRendererProps;
|
|
171
|
+
orderedList: OrderedListRendererProps;
|
|
172
|
+
listItem: ListItemRendererProps;
|
|
173
|
+
link: LinkRendererProps;
|
|
174
|
+
image: ImageRendererProps;
|
|
175
|
+
spacer: SpacerRendererProps;
|
|
176
|
+
};
|
|
177
|
+
export type RendererComponentProps = RendererPropsByTag[MarkdownTag];
|
|
178
|
+
/** Complete map of renderer components (one per tag). Used internally. */
|
|
179
|
+
export type MarkdownComponentMap = {
|
|
180
|
+
[K in MarkdownTag]: ComponentType<RendererPropsByTag[K]>;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Map of custom renderer components keyed by tag.
|
|
184
|
+
* Only the tags you want to override need to be specified;
|
|
185
|
+
* unspecified tags fall back to defaults in `markdownRendererDefaults.tsx`.
|
|
186
|
+
*/
|
|
187
|
+
export type RendererComponentMap = Partial<{
|
|
188
|
+
[K in MarkdownTag]: ComponentType<RendererPropsByTag[K]>;
|
|
189
|
+
}>;
|
|
190
|
+
export type MarkdownSelection = {
|
|
191
|
+
start: number;
|
|
192
|
+
end: number;
|
|
193
|
+
};
|
|
194
|
+
export type MarkdownInlineToolbarAction = 'bold' | 'italic' | 'strikethrough' | 'code';
|
|
195
|
+
export type MarkdownBlockToolbarAction = 'heading' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'quote' | 'unorderedList' | 'orderedList' | 'divider' | 'codeBlock';
|
|
196
|
+
export type MarkdownToolbarAction = MarkdownInlineToolbarAction | MarkdownBlockToolbarAction | 'image';
|
|
197
|
+
export type MarkdownToolbarActionResult = {
|
|
198
|
+
text: string;
|
|
199
|
+
selection: MarkdownSelection;
|
|
200
|
+
activeInlineActions: MarkdownInlineToolbarAction[];
|
|
201
|
+
};
|
|
202
|
+
export type MarkdownRendererProps = {
|
|
203
|
+
markdown: string;
|
|
204
|
+
components?: RendererComponentMap;
|
|
205
|
+
style?: StyleProp<ViewStyle>;
|
|
206
|
+
/**
|
|
207
|
+
* Enabled markdown features.
|
|
208
|
+
* When provided, only the corresponding markdown features are rendered;
|
|
209
|
+
* disabled syntax is treated as plain text.
|
|
210
|
+
*/
|
|
211
|
+
features?: MarkdownToolbarAction[];
|
|
212
|
+
};
|
|
213
|
+
export type UseMarkdownEditorOptions = {
|
|
214
|
+
/** Current markdown text (controlled). */
|
|
215
|
+
value: string;
|
|
216
|
+
/** Called when the text changes. */
|
|
217
|
+
onChangeText: (nextValue: string) => void;
|
|
218
|
+
/** Called when the cursor/selection changes. */
|
|
219
|
+
onSelectionChange?: (selection: MarkdownSelection) => void;
|
|
220
|
+
/** Called after a toolbar action is applied. */
|
|
221
|
+
onToolbarAction?: (action: MarkdownToolbarAction, result: MarkdownToolbarActionResult) => void;
|
|
222
|
+
/**
|
|
223
|
+
* Enabled markdown features.
|
|
224
|
+
* Controls which toolbar buttons appear AND which syntax is highlighted
|
|
225
|
+
* in MarkdownTextInput. Defaults to all features when omitted.
|
|
226
|
+
*/
|
|
227
|
+
features?: MarkdownToolbarAction[];
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Shared editor state returned by `useMarkdownEditor`.
|
|
231
|
+
* Pass as `editor` prop to both `MarkdownTextInput` and `MarkdownToolbar`.
|
|
232
|
+
*/
|
|
233
|
+
export type MarkdownEditorHandle = {
|
|
234
|
+
/** Enabled markdown features. */
|
|
235
|
+
features: MarkdownToolbarAction[];
|
|
236
|
+
/** Current text value. */
|
|
237
|
+
value: string;
|
|
238
|
+
/** Current cursor/selection range. */
|
|
239
|
+
selection: MarkdownSelection;
|
|
240
|
+
/** Currently active inline formatting actions. */
|
|
241
|
+
activeInlineActions: MarkdownInlineToolbarAction[];
|
|
242
|
+
/** Image info when cursor is on an image segment, null otherwise. */
|
|
243
|
+
activeImageInfo: MarkdownImageInfo | null;
|
|
244
|
+
/** Image info set by the toolbar when the user taps the image button (modal state). */
|
|
245
|
+
imageInfo: MarkdownImageInfo | null;
|
|
246
|
+
/** Sets `imageInfo` to the current `activeImageInfo`. Called internally by the toolbar. */
|
|
247
|
+
openImageInfo: () => void;
|
|
248
|
+
/** Clears `imageInfo` (closes the modal). */
|
|
249
|
+
dismissImageInfo: () => void;
|
|
250
|
+
/** Highlighted segments for live preview rendering. */
|
|
251
|
+
highlightedSegments: HighlightSegment[];
|
|
252
|
+
/** Ref to the underlying TextInput. */
|
|
253
|
+
inputRef: React.RefObject<import('react-native').TextInput | null>;
|
|
254
|
+
/** Internal handler - consumed by MarkdownTextInput. */
|
|
255
|
+
handleChangeText: (nextValue: string) => void;
|
|
256
|
+
/** Internal handler - consumed by MarkdownTextInput. */
|
|
257
|
+
handleSelectionChange: (event: {
|
|
258
|
+
nativeEvent: {
|
|
259
|
+
selection: MarkdownSelection;
|
|
260
|
+
};
|
|
261
|
+
}) => void;
|
|
262
|
+
/** Handler for toolbar action presses - consumed by MarkdownToolbar. */
|
|
263
|
+
handleToolbarAction: (action: MarkdownToolbarAction) => void;
|
|
264
|
+
/** Removes the image markdown at the current cursor position (if any). */
|
|
265
|
+
deleteActiveImage: () => void;
|
|
266
|
+
};
|
|
267
|
+
export type MarkdownToolbarButtonState = {
|
|
268
|
+
action: MarkdownToolbarAction;
|
|
269
|
+
active: boolean;
|
|
270
|
+
};
|
|
271
|
+
export type MarkdownToolbarProps = {
|
|
272
|
+
/** Shared editor state from useMarkdownEditor. */
|
|
273
|
+
editor?: MarkdownEditorHandle;
|
|
274
|
+
features?: MarkdownToolbarAction[];
|
|
275
|
+
activeInlineActions?: MarkdownInlineToolbarAction[];
|
|
276
|
+
onPressAction?: (action: MarkdownToolbarAction) => void;
|
|
277
|
+
/** Style for the toolbar container. */
|
|
278
|
+
style?: StyleProp<ViewStyle>;
|
|
279
|
+
/** Static style applied to every button, or a function receiving button state for per-button styling. */
|
|
280
|
+
buttonStyle?: StyleProp<ViewStyle> | ((state: MarkdownToolbarButtonState) => StyleProp<ViewStyle>);
|
|
281
|
+
/** Static text style applied to every button, or a function receiving button state for per-button styling. */
|
|
282
|
+
buttonTextStyle?: StyleProp<TextStyle> | ((state: MarkdownToolbarButtonState) => StyleProp<TextStyle>);
|
|
283
|
+
/** Additional style merged when a button is active. */
|
|
284
|
+
activeButtonStyle?: StyleProp<ViewStyle>;
|
|
285
|
+
/** Additional text style merged when a button is active. */
|
|
286
|
+
activeButtonTextStyle?: StyleProp<TextStyle>;
|
|
287
|
+
/** Additional style merged when a button is inactive. */
|
|
288
|
+
inactiveButtonStyle?: StyleProp<ViewStyle>;
|
|
289
|
+
/** Additional text style merged when a button is inactive. */
|
|
290
|
+
inactiveButtonTextStyle?: StyleProp<TextStyle>;
|
|
291
|
+
renderButton?: (params: {
|
|
292
|
+
action: MarkdownToolbarAction;
|
|
293
|
+
label: string;
|
|
294
|
+
active: boolean;
|
|
295
|
+
onPress: () => void;
|
|
296
|
+
}) => ReactNode;
|
|
297
|
+
};
|
|
298
|
+
export type MarkdownImageInfo = {
|
|
299
|
+
src: string;
|
|
300
|
+
alt: string;
|
|
301
|
+
title?: string;
|
|
302
|
+
/** Start character offset of the image markdown in the text. */
|
|
303
|
+
start: number;
|
|
304
|
+
/** End character offset of the image markdown in the text. */
|
|
305
|
+
end: number;
|
|
306
|
+
};
|
|
307
|
+
export type MarkdownTextInputProps = Omit<TextInputProps, 'value' | 'onChangeText' | 'onSelectionChange' | 'multiline'> & {
|
|
308
|
+
/** Shared editor state from useMarkdownEditor. */
|
|
309
|
+
editor: MarkdownEditorHandle;
|
|
310
|
+
/** Style for the outer container View. */
|
|
311
|
+
style?: StyleProp<ViewStyle>;
|
|
312
|
+
/** Style for the inner TextInput. */
|
|
313
|
+
textInputStyle?: StyleProp<TextStyle>;
|
|
314
|
+
/**
|
|
315
|
+
* Custom components to render specific segment types.
|
|
316
|
+
* Each component must be or extend React Native's Text.
|
|
317
|
+
* Unspecified types fall back to the default Text renderer.
|
|
318
|
+
*/
|
|
319
|
+
segmentComponents?: SegmentComponentMap;
|
|
320
|
+
};
|
|
321
|
+
//# sourceMappingURL=markdownCore.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownCore.types.d.ts","sourceRoot":"","sources":["../src/markdownCore.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,KAAK,EAAE,gBAAgB,EA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,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,cAAc,GAAG,mBAAmB,GAAG,WAAW,CAAC,GAAG;IACzH,kDAAkD;IAClD,MAAM,EAAE,oBAAoB,CAAC;IAC7B,0CAA0C;IAC1C,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,qCAAqC;IACrC,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,mBAAmB,CAAC;CACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownCore.types.js","sourceRoot":"","sources":["../src/markdownCore.types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\nimport type { ComponentType, ReactNode } from 'react';\nimport type { StyleProp, TextInputProps, TextStyle, ViewStyle } from 'react-native';\nimport type { HighlightSegment } from './markdownHighlight.types';\nimport type { SegmentComponentMap } from './markdownSegment.types';\n\nexport type MarkdownTextNode = {\n\ttype: 'text';\n\tcontent: string;\n};\n\nexport type MarkdownBoldNode = {\n\ttype: 'bold';\n\tchildren: MarkdownInlineNode[];\n};\n\nexport type MarkdownItalicNode = {\n\ttype: 'italic';\n\tchildren: MarkdownInlineNode[];\n};\n\nexport type MarkdownInlineCodeNode = {\n\ttype: 'code';\n\tcontent: string;\n};\n\nexport type MarkdownLinkNode = {\n\ttype: 'link';\n\thref: string;\n\tchildren: MarkdownInlineNode[];\n};\n\nexport type MarkdownStrikethroughNode = {\n\ttype: 'strikethrough';\n\tchildren: MarkdownInlineNode[];\n};\n\nexport type MarkdownImageNode = {\n\ttype: 'image';\n\tsrc: string;\n\talt: string;\n\ttitle?: string;\n};\n\nexport type MarkdownInlineNode = MarkdownTextNode | MarkdownBoldNode | MarkdownItalicNode | MarkdownStrikethroughNode | MarkdownInlineCodeNode | MarkdownLinkNode | MarkdownImageNode;\n\nexport type MarkdownParagraphNode = {\n\ttype: 'paragraph';\n\tchildren: MarkdownInlineNode[];\n};\n\nexport type MarkdownHeadingNode = {\n\ttype: 'heading';\n\tlevel: 1 | 2 | 3 | 4 | 5 | 6;\n\tchildren: MarkdownInlineNode[];\n};\n\nexport type MarkdownCodeBlockNode = {\n\ttype: 'codeBlock';\n\tlanguage?: string;\n\tcontent: string;\n};\n\nexport type MarkdownBlockquoteNode = {\n\ttype: 'blockquote';\n\tchildren: MarkdownInlineNode[];\n};\n\nexport type MarkdownHorizontalRuleNode = {\n\ttype: 'horizontalRule';\n};\n\nexport type MarkdownSpacerNode = {\n\ttype: 'spacer';\n};\n\nexport type MarkdownListNode = {\n\ttype: 'list';\n\tordered: boolean;\n\titems: MarkdownInlineNode[][];\n};\n\nexport type MarkdownListItemNode = {\n\ttype: 'listItem';\n\tordered: boolean;\n\tindex: number;\n\tchildren: MarkdownInlineNode[];\n};\n\nexport type MarkdownBlockNode = MarkdownParagraphNode | MarkdownHeadingNode | MarkdownCodeBlockNode | MarkdownBlockquoteNode | MarkdownHorizontalRuleNode | MarkdownSpacerNode | MarkdownListNode;\n\nexport type MarkdownRootNode = {\n\ttype: 'root';\n\tchildren: MarkdownBlockNode[];\n};\n\nexport type MarkdownNode = MarkdownInlineNode | MarkdownBlockNode | MarkdownListItemNode | MarkdownRootNode;\n\nexport type MarkdownTag =\n\t| 'root'\n\t| 'paragraph'\n\t| 'text'\n\t| 'heading1'\n\t| 'heading2'\n\t| 'heading3'\n\t| 'heading4'\n\t| 'heading5'\n\t| 'heading6'\n\t| 'bold'\n\t| 'italic'\n\t| 'strikethrough'\n\t| 'inlineCode'\n\t| 'codeBlock'\n\t| 'blockquote'\n\t| 'horizontalRule'\n\t| 'unorderedList'\n\t| 'orderedList'\n\t| 'listItem'\n\t| 'link'\n\t| 'image'\n\t| 'spacer';\n\n/**\n * Common props shared by every custom renderer component.\n * Unlike segment components (editor), renderer components are NOT constrained\n * to Text — they can use View, Image, or any React Native component.\n */\nexport type RendererBaseProps = {\n\tchildren?: ReactNode;\n};\n\nexport type RootRendererProps = RendererBaseProps & {\n\ttype: 'root';\n\tstyle?: StyleProp<ViewStyle>;\n};\n\nexport type ParagraphRendererProps = RendererBaseProps & {\n\ttype: 'paragraph';\n};\n\nexport type TextRendererProps = RendererBaseProps & {\n\ttype: 'text';\n\ttext: string;\n};\n\nexport type HeadingRendererProps<L extends 1 | 2 | 3 | 4 | 5 | 6> = RendererBaseProps & {\n\ttype: `heading${L}`;\n\tlevel: L;\n};\n\nexport type BoldRendererProps = RendererBaseProps & {\n\ttype: 'bold';\n};\n\nexport type ItalicRendererProps = RendererBaseProps & {\n\ttype: 'italic';\n};\n\nexport type StrikethroughRendererProps = RendererBaseProps & {\n\ttype: 'strikethrough';\n};\n\nexport type InlineCodeRendererProps = RendererBaseProps & {\n\ttype: 'inlineCode';\n\ttext: string;\n};\n\nexport type CodeBlockRendererProps = RendererBaseProps & {\n\ttype: 'codeBlock';\n\ttext: string;\n\tlanguage?: string;\n};\n\nexport type BlockquoteRendererProps = RendererBaseProps & {\n\ttype: 'blockquote';\n};\n\nexport type HorizontalRuleRendererProps = RendererBaseProps & {\n\ttype: 'horizontalRule';\n};\n\nexport type UnorderedListRendererProps = RendererBaseProps & {\n\ttype: 'unorderedList';\n\tordered: false;\n};\n\nexport type OrderedListRendererProps = RendererBaseProps & {\n\ttype: 'orderedList';\n\tordered: true;\n};\n\nexport type ListItemRendererProps = RendererBaseProps & {\n\ttype: 'listItem';\n\tordered: boolean;\n\tindex: number;\n};\n\nexport type LinkRendererProps = RendererBaseProps & {\n\ttype: 'link';\n\thref: string;\n};\n\nexport type ImageRendererProps = RendererBaseProps & {\n\ttype: 'image';\n\tsrc: string;\n\talt: string;\n\ttitle?: string;\n};\n\nexport type SpacerRendererProps = RendererBaseProps & {\n\ttype: 'spacer';\n};\n\nexport type RendererPropsByTag = {\n\troot: RootRendererProps;\n\tparagraph: ParagraphRendererProps;\n\ttext: TextRendererProps;\n\theading1: HeadingRendererProps<1>;\n\theading2: HeadingRendererProps<2>;\n\theading3: HeadingRendererProps<3>;\n\theading4: HeadingRendererProps<4>;\n\theading5: HeadingRendererProps<5>;\n\theading6: HeadingRendererProps<6>;\n\tbold: BoldRendererProps;\n\titalic: ItalicRendererProps;\n\tstrikethrough: StrikethroughRendererProps;\n\tinlineCode: InlineCodeRendererProps;\n\tcodeBlock: CodeBlockRendererProps;\n\tblockquote: BlockquoteRendererProps;\n\thorizontalRule: HorizontalRuleRendererProps;\n\tunorderedList: UnorderedListRendererProps;\n\torderedList: OrderedListRendererProps;\n\tlistItem: ListItemRendererProps;\n\tlink: LinkRendererProps;\n\timage: ImageRendererProps;\n\tspacer: SpacerRendererProps;\n};\n\nexport type RendererComponentProps = RendererPropsByTag[MarkdownTag];\n\n/** Complete map of renderer components (one per tag). Used internally. */\nexport type MarkdownComponentMap = {\n\t[K in MarkdownTag]: ComponentType<RendererPropsByTag[K]>;\n};\n\n/**\n * Map of custom renderer components keyed by tag.\n * Only the tags you want to override need to be specified;\n * unspecified tags fall back to defaults in `markdownRendererDefaults.tsx`.\n */\nexport type RendererComponentMap = Partial<{ [K in MarkdownTag]: ComponentType<RendererPropsByTag[K]> }>;\n\nexport type MarkdownSelection = {\n\tstart: number;\n\tend: number;\n};\n\nexport type MarkdownInlineToolbarAction = 'bold' | 'italic' | 'strikethrough' | 'code';\n\nexport type MarkdownBlockToolbarAction =\n\t| 'heading'\n\t| 'heading1'\n\t| 'heading2'\n\t| 'heading3'\n\t| 'heading4'\n\t| 'heading5'\n\t| 'heading6'\n\t| 'quote'\n\t| 'unorderedList'\n\t| 'orderedList'\n\t| 'divider'\n\t| 'codeBlock';\n\nexport type MarkdownToolbarAction = MarkdownInlineToolbarAction | MarkdownBlockToolbarAction | 'image';\n\nexport type MarkdownToolbarActionResult = {\n\ttext: string;\n\tselection: MarkdownSelection;\n\tactiveInlineActions: MarkdownInlineToolbarAction[];\n};\n\nexport type MarkdownRendererProps = {\n\tmarkdown: string;\n\tcomponents?: RendererComponentMap;\n\tstyle?: StyleProp<ViewStyle>;\n\t/**\n\t * Enabled markdown features.\n\t * When provided, only the corresponding markdown features are rendered;\n\t * disabled syntax is treated as plain text.\n\t */\n\tfeatures?: MarkdownToolbarAction[];\n};\n\n// ---------------------------------------------------------------------------\n// useMarkdownEditor hook\n// ---------------------------------------------------------------------------\n\nexport type UseMarkdownEditorOptions = {\n\t/** Current markdown text (controlled). */\n\tvalue: string;\n\t/** Called when the text changes. */\n\tonChangeText: (nextValue: string) => void;\n\t/** Called when the cursor/selection changes. */\n\tonSelectionChange?: (selection: MarkdownSelection) => void;\n\t/** Called after a toolbar action is applied. */\n\tonToolbarAction?: (action: MarkdownToolbarAction, result: MarkdownToolbarActionResult) => void;\n\t/**\n\t * Enabled markdown features.\n\t * Controls which toolbar buttons appear AND which syntax is highlighted\n\t * in MarkdownTextInput. Defaults to all features when omitted.\n\t */\n\tfeatures?: MarkdownToolbarAction[];\n};\n\n/**\n * Shared editor state returned by `useMarkdownEditor`.\n * Pass as `editor` prop to both `MarkdownTextInput` and `MarkdownToolbar`.\n */\nexport type MarkdownEditorHandle = {\n\t/** Enabled markdown features. */\n\tfeatures: MarkdownToolbarAction[];\n\t/** Current text value. */\n\tvalue: string;\n\t/** Current cursor/selection range. */\n\tselection: MarkdownSelection;\n\t/** Currently active inline formatting actions. */\n\tactiveInlineActions: MarkdownInlineToolbarAction[];\n\t/** Image info when cursor is on an image segment, null otherwise. */\n\tactiveImageInfo: MarkdownImageInfo | null;\n\t/** Image info set by the toolbar when the user taps the image button (modal state). */\n\timageInfo: MarkdownImageInfo | null;\n\t/** Sets `imageInfo` to the current `activeImageInfo`. Called internally by the toolbar. */\n\topenImageInfo: () => void;\n\t/** Clears `imageInfo` (closes the modal). */\n\tdismissImageInfo: () => void;\n\t/** Highlighted segments for live preview rendering. */\n\thighlightedSegments: HighlightSegment[];\n\t/** Ref to the underlying TextInput. */\n\tinputRef: React.RefObject<import('react-native').TextInput | null>;\n\t/** Internal handler - consumed by MarkdownTextInput. */\n\thandleChangeText: (nextValue: string) => void;\n\t/** Internal handler - consumed by MarkdownTextInput. */\n\thandleSelectionChange: (event: { nativeEvent: { selection: MarkdownSelection } }) => void;\n\t/** Handler for toolbar action presses - consumed by MarkdownToolbar. */\n\thandleToolbarAction: (action: MarkdownToolbarAction) => void;\n\t/** Removes the image markdown at the current cursor position (if any). */\n\tdeleteActiveImage: () => void;\n};\n\n// ---------------------------------------------------------------------------\n// Component props\n// ---------------------------------------------------------------------------\n\nexport type MarkdownToolbarButtonState = {\n\taction: MarkdownToolbarAction;\n\tactive: boolean;\n};\n\nexport type MarkdownToolbarProps = {\n\t/** Shared editor state from useMarkdownEditor. */\n\teditor?: MarkdownEditorHandle;\n\tfeatures?: MarkdownToolbarAction[];\n\tactiveInlineActions?: MarkdownInlineToolbarAction[];\n\tonPressAction?: (action: MarkdownToolbarAction) => void;\n\t/** Style for the toolbar container. */\n\tstyle?: StyleProp<ViewStyle>;\n\t/** Static style applied to every button, or a function receiving button state for per-button styling. */\n\tbuttonStyle?: StyleProp<ViewStyle> | ((state: MarkdownToolbarButtonState) => StyleProp<ViewStyle>);\n\t/** Static text style applied to every button, or a function receiving button state for per-button styling. */\n\tbuttonTextStyle?: StyleProp<TextStyle> | ((state: MarkdownToolbarButtonState) => StyleProp<TextStyle>);\n\t/** Additional style merged when a button is active. */\n\tactiveButtonStyle?: StyleProp<ViewStyle>;\n\t/** Additional text style merged when a button is active. */\n\tactiveButtonTextStyle?: StyleProp<TextStyle>;\n\t/** Additional style merged when a button is inactive. */\n\tinactiveButtonStyle?: StyleProp<ViewStyle>;\n\t/** Additional text style merged when a button is inactive. */\n\tinactiveButtonTextStyle?: StyleProp<TextStyle>;\n\trenderButton?: (params: { action: MarkdownToolbarAction; label: string; active: boolean; onPress: () => void }) => ReactNode;\n};\n\nexport type MarkdownImageInfo = {\n\tsrc: string;\n\talt: string;\n\ttitle?: string;\n\t/** Start character offset of the image markdown in the text. */\n\tstart: number;\n\t/** End character offset of the image markdown in the text. */\n\tend: number;\n};\n\nexport type MarkdownTextInputProps = Omit<TextInputProps, 'value' | 'onChangeText' | 'onSelectionChange' | 'multiline'> & {\n\t/** Shared editor state from useMarkdownEditor. */\n\teditor: MarkdownEditorHandle;\n\t/** Style for the outer container View. */\n\tstyle?: StyleProp<ViewStyle>;\n\t/** Style for the inner TextInput. */\n\ttextInputStyle?: StyleProp<TextStyle>;\n\t/**\n\t * Custom components to render specific segment types.\n\t * Each component must be or extend React Native's Text.\n\t * Unspecified types fall back to the default Text renderer.\n\t */\n\tsegmentComponents?: SegmentComponentMap;\n};\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Syntax highlighting module for the live preview editor.
|
|
3
|
+
* Converts raw markdown text into an array of semantic segments,
|
|
4
|
+
* preserving markdown delimiters as visible elements.
|
|
5
|
+
*
|
|
6
|
+
* Unlike the parser in markdownParser.ts (which produces an AST for rendering),
|
|
7
|
+
* this module produces flat {text, type, meta?} segments optimized to be
|
|
8
|
+
* rendered as children of a TextInput.
|
|
9
|
+
*
|
|
10
|
+
* Complexity: O(n) where n is text length.
|
|
11
|
+
*/
|
|
12
|
+
import type { HighlightSegment } from './markdownHighlight.types';
|
|
13
|
+
import type { MarkdownToolbarAction } from './markdownCore.types';
|
|
14
|
+
export type { HighlightSegmentType, HighlightSegment } from './markdownHighlight.types';
|
|
15
|
+
/**
|
|
16
|
+
* Converts markdown text into an array of semantic segments.
|
|
17
|
+
*
|
|
18
|
+
* Parsing happens line by line:
|
|
19
|
+
* 1. Identifies block type (heading, list, quote, code block)
|
|
20
|
+
* 2. Tags block markers (e.g. #, >, -) with dedicated segment types
|
|
21
|
+
* 3. Analyzes inline content (bold, italic, code, link)
|
|
22
|
+
* 4. Produces semantic segments rendered via segment components
|
|
23
|
+
*
|
|
24
|
+
* @param markdown - Raw markdown text
|
|
25
|
+
* @param features - Optional list of enabled features. When provided,
|
|
26
|
+
* only the corresponding syntax is highlighted; disabled
|
|
27
|
+
* syntax is treated as plain text.
|
|
28
|
+
* @returns Array of semantic segments
|
|
29
|
+
*/
|
|
30
|
+
export declare function highlightMarkdown(markdown: string, features?: MarkdownToolbarAction[]): HighlightSegment[];
|
|
31
|
+
//# sourceMappingURL=markdownHighlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownHighlight.d.ts","sourceRoot":"","sources":["../src/markdownHighlight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAwB,gBAAgB,EAAsD,MAAM,2BAA2B,CAAC;AAC5I,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAuBxF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,qBAAqB,EAAE,GAAG,gBAAgB,EAAE,CAuH1G"}
|