react-native-jet-markdown 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -56
- package/android/src/main/cpp/JniBindings.cpp +0 -106
- package/android/src/main/java/com/jetmarkdown/JetMarkdownNative.kt +0 -79
- package/android/src/main/java/com/jetmarkdown/JetMarkdownPackage.kt +1 -2
- package/android/src/main/java/com/jetmarkdown/render/spans/MarkdownLineHeightSpan.kt +2 -13
- package/cpp/react/override/react/renderer/components/JetMarkdownViewSpec/ComponentDescriptors.h +0 -4
- package/cpp/tests/parser_tests.cpp +0 -402
- package/cpp/tests/run_tests.sh +0 -3
- package/ios/JetMarkdownView.mm +33 -2
- package/lib/module/index.js +0 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +0 -127
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +2 -5
- package/src/index.tsx +0 -9
- package/src/types.ts +0 -134
- package/android/src/main/java/com/jetmarkdown/editor/EditorSpans.kt +0 -217
- package/android/src/main/java/com/jetmarkdown/editor/JetMarkdownEditorManager.kt +0 -224
- package/android/src/main/java/com/jetmarkdown/editor/JetMarkdownEditorView.kt +0 -1736
- package/cpp/core/AstToMarkdown.cpp +0 -549
- package/cpp/core/AstToMarkdown.h +0 -16
- package/cpp/core/EditorRuns.cpp +0 -640
- package/cpp/core/EditorRuns.h +0 -94
- package/cpp/core/EditorText.cpp +0 -15
- package/cpp/core/EditorText.h +0 -18
- package/cpp/react/JetMarkdownEditorShadowNode.cpp +0 -54
- package/cpp/react/JetMarkdownEditorShadowNode.h +0 -55
- package/cpp/react/JetMarkdownEditorState.h +0 -35
- package/ios/editor/JetMarkdownEditor.h +0 -12
- package/ios/editor/JetMarkdownEditor.mm +0 -2002
- package/lib/module/JetMarkdownEditor.js +0 -85
- package/lib/module/JetMarkdownEditor.js.map +0 -1
- package/lib/module/JetMarkdownEditor.native.js +0 -244
- package/lib/module/JetMarkdownEditor.native.js.map +0 -1
- package/lib/module/JetMarkdownEditorNativeComponent.ts +0 -173
- package/lib/module/useJetMarkdownEditor.js +0 -41
- package/lib/module/useJetMarkdownEditor.js.map +0 -1
- package/lib/typescript/src/JetMarkdownEditor.d.ts +0 -6
- package/lib/typescript/src/JetMarkdownEditor.d.ts.map +0 -1
- package/lib/typescript/src/JetMarkdownEditor.native.d.ts +0 -6
- package/lib/typescript/src/JetMarkdownEditor.native.d.ts.map +0 -1
- package/lib/typescript/src/JetMarkdownEditorNativeComponent.d.ts +0 -105
- package/lib/typescript/src/JetMarkdownEditorNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/useJetMarkdownEditor.d.ts +0 -36
- package/lib/typescript/src/useJetMarkdownEditor.d.ts.map +0 -1
- package/src/JetMarkdownEditor.native.tsx +0 -301
- package/src/JetMarkdownEditor.tsx +0 -90
- package/src/JetMarkdownEditorNativeComponent.ts +0 -173
- package/src/useJetMarkdownEditor.ts +0 -50
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { type CodegenTypes, type ColorValue, type HostComponent, type ViewProps } from "react-native";
|
|
2
|
-
interface TextEvent {
|
|
3
|
-
text: string;
|
|
4
|
-
}
|
|
5
|
-
interface MarkdownEvent {
|
|
6
|
-
markdown: string;
|
|
7
|
-
}
|
|
8
|
-
interface SelectionEvent {
|
|
9
|
-
end: CodegenTypes.Int32;
|
|
10
|
-
start: CodegenTypes.Int32;
|
|
11
|
-
}
|
|
12
|
-
interface StateEvent {
|
|
13
|
-
headingLevel: CodegenTypes.Int32;
|
|
14
|
-
isBlockQuote: boolean;
|
|
15
|
-
isBold: boolean;
|
|
16
|
-
isCodeBlock: boolean;
|
|
17
|
-
isInlineCode: boolean;
|
|
18
|
-
isItalic: boolean;
|
|
19
|
-
isOrderedList: boolean;
|
|
20
|
-
isSpoiler: boolean;
|
|
21
|
-
isStrikethrough: boolean;
|
|
22
|
-
isSubscript: boolean;
|
|
23
|
-
isSuperscript: boolean;
|
|
24
|
-
isUnorderedList: boolean;
|
|
25
|
-
}
|
|
26
|
-
interface UrlEvent {
|
|
27
|
-
url: string;
|
|
28
|
-
}
|
|
29
|
-
interface MentionEvent {
|
|
30
|
-
trigger: string;
|
|
31
|
-
}
|
|
32
|
-
interface MentionQueryEvent {
|
|
33
|
-
query: string;
|
|
34
|
-
trigger: string;
|
|
35
|
-
}
|
|
36
|
-
interface PasteEvent {
|
|
37
|
-
images: {
|
|
38
|
-
height: CodegenTypes.Double;
|
|
39
|
-
url: string;
|
|
40
|
-
width: CodegenTypes.Double;
|
|
41
|
-
}[];
|
|
42
|
-
text: string;
|
|
43
|
-
}
|
|
44
|
-
interface NativeProps extends ViewProps {
|
|
45
|
-
allowFontScaling?: CodegenTypes.WithDefault<boolean, true>;
|
|
46
|
-
autoCapitalize?: CodegenTypes.WithDefault<"none" | "sentences" | "words" | "characters", "sentences">;
|
|
47
|
-
autoCorrect?: CodegenTypes.WithDefault<boolean, true>;
|
|
48
|
-
autoFocus?: CodegenTypes.WithDefault<boolean, false>;
|
|
49
|
-
cursorColor?: ColorValue;
|
|
50
|
-
defaultValue?: string;
|
|
51
|
-
editable?: CodegenTypes.WithDefault<boolean, true>;
|
|
52
|
-
/**
|
|
53
|
-
* Autogrow cap in points; native default 0 = unbounded. Yoga ALSO parses
|
|
54
|
-
* this key out of the raw-props bag as max-height, so the wrapper MUST
|
|
55
|
-
* omit it entirely when unset — an unconditional 0 clamps the node to
|
|
56
|
-
* zero height (dead flex-sized editors). When set, Yoga's clamp equals
|
|
57
|
-
* the autogrow cap, which is exactly the intended geometry.
|
|
58
|
-
*/
|
|
59
|
-
maxHeight?: CodegenTypes.WithDefault<CodegenTypes.Double, 0>;
|
|
60
|
-
mentionTriggers?: readonly string[];
|
|
61
|
-
multiline?: CodegenTypes.WithDefault<boolean, true>;
|
|
62
|
-
onEditorBlur?: CodegenTypes.DirectEventHandler<null>;
|
|
63
|
-
onEditorChangeMarkdown?: CodegenTypes.DirectEventHandler<MarkdownEvent>;
|
|
64
|
-
onEditorChangeSelection?: CodegenTypes.DirectEventHandler<SelectionEvent>;
|
|
65
|
-
onEditorChangeState?: CodegenTypes.DirectEventHandler<StateEvent>;
|
|
66
|
-
onEditorChangeText?: CodegenTypes.DirectEventHandler<TextEvent>;
|
|
67
|
-
onEditorFocus?: CodegenTypes.DirectEventHandler<null>;
|
|
68
|
-
onEditorLinkDetected?: CodegenTypes.DirectEventHandler<UrlEvent>;
|
|
69
|
-
onEditorMentionChange?: CodegenTypes.DirectEventHandler<MentionQueryEvent>;
|
|
70
|
-
onEditorMentionEnd?: CodegenTypes.DirectEventHandler<MentionEvent>;
|
|
71
|
-
onEditorMentionStart?: CodegenTypes.DirectEventHandler<MentionEvent>;
|
|
72
|
-
onEditorPaste?: CodegenTypes.DirectEventHandler<PasteEvent>;
|
|
73
|
-
placeholder?: string;
|
|
74
|
-
placeholderTextColor?: ColorValue;
|
|
75
|
-
scrollEnabled?: CodegenTypes.WithDefault<boolean, false>;
|
|
76
|
-
selectionColor?: ColorValue;
|
|
77
|
-
stylesJson?: string;
|
|
78
|
-
}
|
|
79
|
-
type EditorComponentType = HostComponent<NativeProps>;
|
|
80
|
-
interface NativeCommands {
|
|
81
|
-
blur: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
82
|
-
focus: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
83
|
-
insertLink: (viewRef: React.ElementRef<EditorComponentType>, url: string, label: string) => void;
|
|
84
|
-
insertMarkdown: (viewRef: React.ElementRef<EditorComponentType>, value: string) => void;
|
|
85
|
-
insertMention: (viewRef: React.ElementRef<EditorComponentType>, trigger: string, label: string, url: string) => void;
|
|
86
|
-
removeLink: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
87
|
-
setSelection: (viewRef: React.ElementRef<EditorComponentType>, start: CodegenTypes.Int32, end: CodegenTypes.Int32) => void;
|
|
88
|
-
setValue: (viewRef: React.ElementRef<EditorComponentType>, value: string) => void;
|
|
89
|
-
toggleBlockQuote: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
90
|
-
toggleBold: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
91
|
-
toggleCode: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
92
|
-
toggleCodeBlock: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
93
|
-
toggleHeading: (viewRef: React.ElementRef<EditorComponentType>, level: CodegenTypes.Int32) => void;
|
|
94
|
-
toggleItalic: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
95
|
-
toggleOrderedList: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
96
|
-
toggleSpoiler: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
97
|
-
toggleStrikethrough: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
98
|
-
toggleSubscript: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
99
|
-
toggleSuperscript: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
100
|
-
toggleUnorderedList: (viewRef: React.ElementRef<EditorComponentType>) => void;
|
|
101
|
-
}
|
|
102
|
-
export declare const Commands: NativeCommands;
|
|
103
|
-
declare const _default: import("react-native/types_generated/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
104
|
-
export default _default;
|
|
105
|
-
//# sourceMappingURL=JetMarkdownEditorNativeComponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JetMarkdownEditorNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/JetMarkdownEditorNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EAGf,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,aAAa;IACrB,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C/E;AAED,eAAO,MAAM,QAAQ,gBAuBnB,CAAC;;AAEH,wBAAwE"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { JetMarkdownEditorRef } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Convenience hook: a ref to pass to `<JetMarkdownEditor>` plus stable
|
|
4
|
-
* callbacks for every editor command.
|
|
5
|
-
*
|
|
6
|
-
* ```tsx
|
|
7
|
-
* const editor = useJetMarkdownEditor();
|
|
8
|
-
* <JetMarkdownEditor ref={editor.ref} />
|
|
9
|
-
* <Button onPress={editor.focus} />
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export declare function useJetMarkdownEditor(): {
|
|
13
|
-
blur: () => void | undefined;
|
|
14
|
-
focus: () => void | undefined;
|
|
15
|
-
getMarkdown: () => Promise<string>;
|
|
16
|
-
insertLink: (url: string, label?: string) => void | undefined;
|
|
17
|
-
insertMarkdown: (markdown: string) => void | undefined;
|
|
18
|
-
insertMention: (trigger: string, label: string, url: string) => void | undefined;
|
|
19
|
-
ref: import("react").RefObject<JetMarkdownEditorRef | null>;
|
|
20
|
-
removeLink: () => void | undefined;
|
|
21
|
-
setSelection: (start: number, end: number) => void | undefined;
|
|
22
|
-
setValue: (markdown: string) => void | undefined;
|
|
23
|
-
toggleBlockQuote: () => void | undefined;
|
|
24
|
-
toggleBold: () => void | undefined;
|
|
25
|
-
toggleCode: () => void | undefined;
|
|
26
|
-
toggleCodeBlock: () => void | undefined;
|
|
27
|
-
toggleHeading: (level: number) => void | undefined;
|
|
28
|
-
toggleItalic: () => void | undefined;
|
|
29
|
-
toggleOrderedList: () => void | undefined;
|
|
30
|
-
toggleSpoiler: () => void | undefined;
|
|
31
|
-
toggleStrikethrough: () => void | undefined;
|
|
32
|
-
toggleSubscript: () => void | undefined;
|
|
33
|
-
toggleSuperscript: () => void | undefined;
|
|
34
|
-
toggleUnorderedList: () => void | undefined;
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=useJetMarkdownEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useJetMarkdownEditor.d.ts","sourceRoot":"","sources":["../../../src/useJetMarkdownEditor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAS,CAAC;AAEpD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB;;;uBAOb,OAAO,CAAC,MAAM,CAAC;sBAEd,MAAM,UAAU,MAAM;+BAEb,MAAM;6BAER,MAAM,SAAS,MAAM,OAAO,MAAM;;;0BAIrC,MAAM,OAAO,MAAM;yBAEpB,MAAM;;;;;2BAKJ,MAAM;;;;;;;;EAWlC"}
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Ref,
|
|
3
|
-
useCallback,
|
|
4
|
-
useImperativeHandle,
|
|
5
|
-
useMemo,
|
|
6
|
-
useRef,
|
|
7
|
-
} from "react";
|
|
8
|
-
import type { NativeSyntheticEvent } from "react-native";
|
|
9
|
-
|
|
10
|
-
import NativeJetMarkdownEditor, {
|
|
11
|
-
Commands,
|
|
12
|
-
} from "./JetMarkdownEditorNativeComponent";
|
|
13
|
-
import {
|
|
14
|
-
type MainStyle,
|
|
15
|
-
serializeStyles,
|
|
16
|
-
splitContainerStyle,
|
|
17
|
-
} from "./serializeStyles";
|
|
18
|
-
import type {
|
|
19
|
-
JetMarkdownEditorProps,
|
|
20
|
-
JetMarkdownEditorRef,
|
|
21
|
-
MarkdownImageData,
|
|
22
|
-
MarkdownSelection,
|
|
23
|
-
} from "./types";
|
|
24
|
-
|
|
25
|
-
type NativeEditor = React.ElementRef<typeof NativeJetMarkdownEditor>;
|
|
26
|
-
|
|
27
|
-
export function JetMarkdownEditor({
|
|
28
|
-
allowFontScaling,
|
|
29
|
-
autoCapitalize,
|
|
30
|
-
autoCorrect,
|
|
31
|
-
autoFocus,
|
|
32
|
-
cursorColor,
|
|
33
|
-
defaultValue,
|
|
34
|
-
editable,
|
|
35
|
-
mentionTriggers,
|
|
36
|
-
multiline,
|
|
37
|
-
onBlur,
|
|
38
|
-
onChangeMarkdown,
|
|
39
|
-
onChangeSelection,
|
|
40
|
-
onChangeState,
|
|
41
|
-
onChangeText,
|
|
42
|
-
onFocus,
|
|
43
|
-
onLinkDetected,
|
|
44
|
-
onMentionChange,
|
|
45
|
-
onMentionEnd,
|
|
46
|
-
onMentionStart,
|
|
47
|
-
onPaste,
|
|
48
|
-
placeholder,
|
|
49
|
-
placeholderTextColor,
|
|
50
|
-
scrollEnabled,
|
|
51
|
-
selectionColor,
|
|
52
|
-
style,
|
|
53
|
-
styles,
|
|
54
|
-
ref,
|
|
55
|
-
}: JetMarkdownEditorProps & { ref?: Ref<JetMarkdownEditorRef> }) {
|
|
56
|
-
const nativeRef = useRef<NativeEditor>(null);
|
|
57
|
-
// getMarkdown resolves from the latest onEditorChangeMarkdown payload;
|
|
58
|
-
// until the serializer emits (E1), plain text doubles as the markdown.
|
|
59
|
-
const markdownRef = useRef<string | null>(null);
|
|
60
|
-
const textRef = useRef<string>(defaultValue ?? "");
|
|
61
|
-
|
|
62
|
-
const { hostStyle, main } = splitContainerStyle(style);
|
|
63
|
-
// maxHeight rides as a native prop (autogrow cap; the editor scrolls
|
|
64
|
-
// internally past it) instead of a host style key. It is omitted when
|
|
65
|
-
// unset: Yoga reads the same raw prop as max-height, and a 0 would clamp
|
|
66
|
-
// flex-sized editors to zero height.
|
|
67
|
-
const { maxHeight, ...editorHostStyle } = hostStyle;
|
|
68
|
-
const mainKey = JSON.stringify(main);
|
|
69
|
-
const stylesJson = useMemo(
|
|
70
|
-
() => serializeStyles(styles, JSON.parse(mainKey) as MainStyle),
|
|
71
|
-
[styles, mainKey]
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
useImperativeHandle(
|
|
75
|
-
ref,
|
|
76
|
-
(): JetMarkdownEditorRef => ({
|
|
77
|
-
blur: () => {
|
|
78
|
-
if (nativeRef.current) {
|
|
79
|
-
Commands.blur(nativeRef.current);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
focus: () => {
|
|
83
|
-
if (nativeRef.current) {
|
|
84
|
-
Commands.focus(nativeRef.current);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
getMarkdown: () =>
|
|
88
|
-
Promise.resolve(markdownRef.current ?? textRef.current),
|
|
89
|
-
insertLink: (url: string, label?: string) => {
|
|
90
|
-
if (nativeRef.current) {
|
|
91
|
-
Commands.insertLink(nativeRef.current, url, label ?? "");
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
insertMarkdown: (markdown: string) => {
|
|
95
|
-
if (nativeRef.current) {
|
|
96
|
-
Commands.insertMarkdown(nativeRef.current, markdown);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
insertMention: (trigger: string, label: string, url: string) => {
|
|
100
|
-
if (nativeRef.current) {
|
|
101
|
-
Commands.insertMention(nativeRef.current, trigger, label, url);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
removeLink: () => {
|
|
105
|
-
if (nativeRef.current) {
|
|
106
|
-
Commands.removeLink(nativeRef.current);
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
setSelection: (start: number, end: number) => {
|
|
110
|
-
if (nativeRef.current) {
|
|
111
|
-
Commands.setSelection(nativeRef.current, start, end);
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
setValue: (markdown: string) => {
|
|
115
|
-
// Seed with the value being set so getMarkdown() never reports the
|
|
116
|
-
// pre-setValue document; native re-emits its canonical serialization
|
|
117
|
-
// right after.
|
|
118
|
-
markdownRef.current = markdown;
|
|
119
|
-
textRef.current = markdown;
|
|
120
|
-
if (nativeRef.current) {
|
|
121
|
-
Commands.setValue(nativeRef.current, markdown);
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
toggleBlockQuote: () => {
|
|
125
|
-
if (nativeRef.current) {
|
|
126
|
-
Commands.toggleBlockQuote(nativeRef.current);
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
toggleBold: () => {
|
|
130
|
-
if (nativeRef.current) {
|
|
131
|
-
Commands.toggleBold(nativeRef.current);
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
toggleCode: () => {
|
|
135
|
-
if (nativeRef.current) {
|
|
136
|
-
Commands.toggleCode(nativeRef.current);
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
toggleCodeBlock: () => {
|
|
140
|
-
if (nativeRef.current) {
|
|
141
|
-
Commands.toggleCodeBlock(nativeRef.current);
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
toggleHeading: (level: number) => {
|
|
145
|
-
if (nativeRef.current) {
|
|
146
|
-
Commands.toggleHeading(nativeRef.current, level);
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
toggleItalic: () => {
|
|
150
|
-
if (nativeRef.current) {
|
|
151
|
-
Commands.toggleItalic(nativeRef.current);
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
toggleOrderedList: () => {
|
|
155
|
-
if (nativeRef.current) {
|
|
156
|
-
Commands.toggleOrderedList(nativeRef.current);
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
toggleSpoiler: () => {
|
|
160
|
-
if (nativeRef.current) {
|
|
161
|
-
Commands.toggleSpoiler(nativeRef.current);
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
toggleStrikethrough: () => {
|
|
165
|
-
if (nativeRef.current) {
|
|
166
|
-
Commands.toggleStrikethrough(nativeRef.current);
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
toggleSubscript: () => {
|
|
170
|
-
if (nativeRef.current) {
|
|
171
|
-
Commands.toggleSubscript(nativeRef.current);
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
toggleSuperscript: () => {
|
|
175
|
-
if (nativeRef.current) {
|
|
176
|
-
Commands.toggleSuperscript(nativeRef.current);
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
toggleUnorderedList: () => {
|
|
180
|
-
if (nativeRef.current) {
|
|
181
|
-
Commands.toggleUnorderedList(nativeRef.current);
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
}),
|
|
185
|
-
[]
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
// The native side never inserts pasted content itself: it reports the
|
|
189
|
-
// clipboard here, and unless the app's onPaste calls preventDefault()
|
|
190
|
-
// synchronously, the default insertion happens via insertMarkdown.
|
|
191
|
-
const handlePaste = useCallback(
|
|
192
|
-
(
|
|
193
|
-
event: NativeSyntheticEvent<{
|
|
194
|
-
images: readonly MarkdownImageData[];
|
|
195
|
-
text: string;
|
|
196
|
-
}>
|
|
197
|
-
) => {
|
|
198
|
-
const { images, text } = event.nativeEvent;
|
|
199
|
-
let prevented = false;
|
|
200
|
-
onPaste?.({
|
|
201
|
-
images: images.length > 0 ? [...images] : undefined,
|
|
202
|
-
preventDefault: () => {
|
|
203
|
-
prevented = true;
|
|
204
|
-
},
|
|
205
|
-
text: text.length > 0 ? text : undefined,
|
|
206
|
-
});
|
|
207
|
-
if (!prevented && text.length > 0 && nativeRef.current) {
|
|
208
|
-
Commands.insertMarkdown(nativeRef.current, text);
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
[onPaste]
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
return (
|
|
215
|
-
<NativeJetMarkdownEditor
|
|
216
|
-
allowFontScaling={allowFontScaling}
|
|
217
|
-
autoCapitalize={autoCapitalize}
|
|
218
|
-
autoCorrect={autoCorrect}
|
|
219
|
-
autoFocus={autoFocus}
|
|
220
|
-
cursorColor={cursorColor}
|
|
221
|
-
defaultValue={defaultValue}
|
|
222
|
-
editable={editable}
|
|
223
|
-
maxHeight={
|
|
224
|
-
typeof maxHeight === "number" && maxHeight > 0 ? maxHeight : undefined
|
|
225
|
-
}
|
|
226
|
-
mentionTriggers={mentionTriggers}
|
|
227
|
-
multiline={multiline}
|
|
228
|
-
onEditorBlur={onBlur ? () => onBlur() : undefined}
|
|
229
|
-
onEditorChangeMarkdown={(
|
|
230
|
-
event: NativeSyntheticEvent<{ markdown: string }>
|
|
231
|
-
) => {
|
|
232
|
-
markdownRef.current = event.nativeEvent.markdown;
|
|
233
|
-
onChangeMarkdown?.(event.nativeEvent.markdown);
|
|
234
|
-
}}
|
|
235
|
-
onEditorChangeSelection={
|
|
236
|
-
onChangeSelection
|
|
237
|
-
? (event: NativeSyntheticEvent<MarkdownSelection>) =>
|
|
238
|
-
onChangeSelection({
|
|
239
|
-
end: event.nativeEvent.end,
|
|
240
|
-
start: event.nativeEvent.start,
|
|
241
|
-
})
|
|
242
|
-
: undefined
|
|
243
|
-
}
|
|
244
|
-
onEditorChangeState={
|
|
245
|
-
onChangeState
|
|
246
|
-
? (event) => {
|
|
247
|
-
// Copy the declared fields so consumers never see the raw
|
|
248
|
-
// nativeEvent extras (target, etc.).
|
|
249
|
-
const state = event.nativeEvent;
|
|
250
|
-
onChangeState({
|
|
251
|
-
headingLevel: state.headingLevel,
|
|
252
|
-
isBlockQuote: state.isBlockQuote,
|
|
253
|
-
isBold: state.isBold,
|
|
254
|
-
isCodeBlock: state.isCodeBlock,
|
|
255
|
-
isInlineCode: state.isInlineCode,
|
|
256
|
-
isItalic: state.isItalic,
|
|
257
|
-
isOrderedList: state.isOrderedList,
|
|
258
|
-
isSpoiler: state.isSpoiler,
|
|
259
|
-
isStrikethrough: state.isStrikethrough,
|
|
260
|
-
isSubscript: state.isSubscript,
|
|
261
|
-
isSuperscript: state.isSuperscript,
|
|
262
|
-
isUnorderedList: state.isUnorderedList,
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
: undefined
|
|
266
|
-
}
|
|
267
|
-
onEditorChangeText={(event: NativeSyntheticEvent<{ text: string }>) => {
|
|
268
|
-
textRef.current = event.nativeEvent.text;
|
|
269
|
-
onChangeText?.(event.nativeEvent.text);
|
|
270
|
-
}}
|
|
271
|
-
onEditorFocus={onFocus ? () => onFocus() : undefined}
|
|
272
|
-
onEditorLinkDetected={
|
|
273
|
-
onLinkDetected
|
|
274
|
-
? (event: NativeSyntheticEvent<{ url: string }>) =>
|
|
275
|
-
onLinkDetected({ url: event.nativeEvent.url })
|
|
276
|
-
: undefined
|
|
277
|
-
}
|
|
278
|
-
onEditorMentionChange={
|
|
279
|
-
onMentionChange
|
|
280
|
-
? (event) => onMentionChange(event.nativeEvent)
|
|
281
|
-
: undefined
|
|
282
|
-
}
|
|
283
|
-
onEditorMentionEnd={
|
|
284
|
-
onMentionEnd ? (event) => onMentionEnd(event.nativeEvent) : undefined
|
|
285
|
-
}
|
|
286
|
-
onEditorMentionStart={
|
|
287
|
-
onMentionStart
|
|
288
|
-
? (event) => onMentionStart(event.nativeEvent)
|
|
289
|
-
: undefined
|
|
290
|
-
}
|
|
291
|
-
onEditorPaste={handlePaste}
|
|
292
|
-
placeholder={placeholder}
|
|
293
|
-
placeholderTextColor={placeholderTextColor}
|
|
294
|
-
ref={nativeRef}
|
|
295
|
-
scrollEnabled={scrollEnabled}
|
|
296
|
-
selectionColor={selectionColor}
|
|
297
|
-
style={editorHostStyle}
|
|
298
|
-
stylesJson={stylesJson}
|
|
299
|
-
/>
|
|
300
|
-
);
|
|
301
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { type Ref, useImperativeHandle, useRef } from "react";
|
|
2
|
-
import { type StyleProp, TextInput, type TextStyle } from "react-native";
|
|
3
|
-
|
|
4
|
-
import type { JetMarkdownEditorProps, JetMarkdownEditorRef } from "./types";
|
|
5
|
-
|
|
6
|
-
// Non-native (web) fallback: a plain multiline text input over raw markdown.
|
|
7
|
-
export function JetMarkdownEditor({
|
|
8
|
-
allowFontScaling,
|
|
9
|
-
autoCapitalize,
|
|
10
|
-
autoCorrect,
|
|
11
|
-
autoFocus,
|
|
12
|
-
cursorColor,
|
|
13
|
-
defaultValue,
|
|
14
|
-
editable,
|
|
15
|
-
multiline = true,
|
|
16
|
-
onBlur,
|
|
17
|
-
onChangeMarkdown,
|
|
18
|
-
onChangeText,
|
|
19
|
-
onFocus,
|
|
20
|
-
placeholder,
|
|
21
|
-
placeholderTextColor,
|
|
22
|
-
scrollEnabled,
|
|
23
|
-
selectionColor,
|
|
24
|
-
style,
|
|
25
|
-
ref,
|
|
26
|
-
}: JetMarkdownEditorProps & { ref?: Ref<JetMarkdownEditorRef> }) {
|
|
27
|
-
const inputRef = useRef<React.ComponentRef<typeof TextInput>>(null);
|
|
28
|
-
const textRef = useRef(defaultValue ?? "");
|
|
29
|
-
|
|
30
|
-
useImperativeHandle(
|
|
31
|
-
ref,
|
|
32
|
-
(): JetMarkdownEditorRef => ({
|
|
33
|
-
blur: () => inputRef.current?.blur(),
|
|
34
|
-
focus: () => inputRef.current?.focus(),
|
|
35
|
-
getMarkdown: () => Promise.resolve(textRef.current),
|
|
36
|
-
insertLink: () => undefined,
|
|
37
|
-
insertMarkdown: () => undefined,
|
|
38
|
-
insertMention: () => undefined,
|
|
39
|
-
removeLink: () => undefined,
|
|
40
|
-
setSelection: () => {
|
|
41
|
-
// Not supported in the web fallback.
|
|
42
|
-
},
|
|
43
|
-
setValue: (markdown: string) => {
|
|
44
|
-
textRef.current = markdown;
|
|
45
|
-
inputRef.current?.setNativeProps({ text: markdown });
|
|
46
|
-
},
|
|
47
|
-
// Formatting toggles are not supported in the web fallback (raw
|
|
48
|
-
// markdown).
|
|
49
|
-
toggleBlockQuote: () => undefined,
|
|
50
|
-
toggleBold: () => undefined,
|
|
51
|
-
toggleCode: () => undefined,
|
|
52
|
-
toggleCodeBlock: () => undefined,
|
|
53
|
-
toggleHeading: () => undefined,
|
|
54
|
-
toggleItalic: () => undefined,
|
|
55
|
-
toggleOrderedList: () => undefined,
|
|
56
|
-
toggleSpoiler: () => undefined,
|
|
57
|
-
toggleStrikethrough: () => undefined,
|
|
58
|
-
toggleSubscript: () => undefined,
|
|
59
|
-
toggleSuperscript: () => undefined,
|
|
60
|
-
toggleUnorderedList: () => undefined,
|
|
61
|
-
}),
|
|
62
|
-
[]
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<TextInput
|
|
67
|
-
allowFontScaling={allowFontScaling}
|
|
68
|
-
autoCapitalize={autoCapitalize}
|
|
69
|
-
autoCorrect={autoCorrect}
|
|
70
|
-
autoFocus={autoFocus}
|
|
71
|
-
cursorColor={cursorColor}
|
|
72
|
-
defaultValue={defaultValue}
|
|
73
|
-
editable={editable}
|
|
74
|
-
multiline={multiline}
|
|
75
|
-
onBlur={onBlur}
|
|
76
|
-
onChangeText={(text) => {
|
|
77
|
-
textRef.current = text;
|
|
78
|
-
onChangeText?.(text);
|
|
79
|
-
onChangeMarkdown?.(text);
|
|
80
|
-
}}
|
|
81
|
-
onFocus={onFocus}
|
|
82
|
-
placeholder={placeholder}
|
|
83
|
-
placeholderTextColor={placeholderTextColor}
|
|
84
|
-
ref={inputRef}
|
|
85
|
-
scrollEnabled={scrollEnabled}
|
|
86
|
-
selectionColor={selectionColor}
|
|
87
|
-
style={style as StyleProp<TextStyle>}
|
|
88
|
-
/>
|
|
89
|
-
);
|
|
90
|
-
}
|