@apollohg/react-native-prose-editor 0.1.1 → 0.3.0
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 +12 -7
- package/android/build.gradle +7 -2
- package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +289 -2
- package/android/src/main/java/com/apollohg/editor/EditorTheme.kt +51 -1
- package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +199 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +16 -3
- package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +82 -1
- package/android/src/main/java/com/apollohg/editor/NativeToolbar.kt +403 -45
- package/android/src/main/java/com/apollohg/editor/RemoteSelectionOverlayView.kt +246 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridge.kt +841 -155
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +125 -8
- package/{src/EditorTheme.ts → dist/EditorTheme.d.ts} +12 -52
- package/dist/EditorTheme.js +29 -0
- package/dist/EditorToolbar.d.ts +129 -0
- package/dist/EditorToolbar.js +394 -0
- package/dist/NativeEditorBridge.d.ts +242 -0
- package/dist/NativeEditorBridge.js +647 -0
- package/dist/NativeRichTextEditor.d.ts +142 -0
- package/dist/NativeRichTextEditor.js +649 -0
- package/dist/YjsCollaboration.d.ts +83 -0
- package/dist/YjsCollaboration.js +585 -0
- package/dist/addons.d.ts +70 -0
- package/dist/addons.js +77 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +26 -0
- package/dist/schemas.d.ts +35 -0
- package/{src/schemas.ts → dist/schemas.js} +62 -27
- package/dist/useNativeEditor.d.ts +40 -0
- package/dist/useNativeEditor.js +117 -0
- package/ios/EditorAddons.swift +26 -3
- package/ios/EditorCore.xcframework/Info.plist +5 -5
- package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
- package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
- package/ios/EditorLayoutManager.swift +236 -0
- package/ios/EditorTheme.swift +51 -1
- package/ios/Generated_editor_core.swift +270 -2
- package/ios/NativeEditorExpoView.swift +612 -45
- package/ios/NativeEditorModule.swift +81 -0
- package/ios/PositionBridge.swift +22 -0
- package/ios/RenderBridge.swift +427 -39
- package/ios/RichTextEditorView.swift +1342 -18
- package/ios/editor_coreFFI/editor_coreFFI.h +209 -0
- package/package.json +80 -64
- package/rust/android/arm64-v8a/libeditor_core.so +0 -0
- package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
- package/rust/android/x86_64/libeditor_core.so +0 -0
- package/rust/bindings/kotlin/uniffi/editor_core/editor_core.kt +404 -4
- package/src/EditorToolbar.tsx +0 -620
- package/src/NativeEditorBridge.ts +0 -607
- package/src/NativeRichTextEditor.tsx +0 -951
- package/src/addons.ts +0 -158
- package/src/index.ts +0 -63
- package/src/useNativeEditor.ts +0 -173
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import { type ActiveState, type DocumentJSON, type HistoryState, type Selection } from './NativeEditorBridge';
|
|
4
|
+
import { type EditorToolbarItem } from './EditorToolbar';
|
|
5
|
+
import { type EditorTheme } from './EditorTheme';
|
|
6
|
+
import { type EditorAddons } from './addons';
|
|
7
|
+
import { type SchemaDefinition } from './schemas';
|
|
8
|
+
import { type ImageNodeAttributes } from './schemas';
|
|
9
|
+
export type NativeRichTextEditorHeightBehavior = 'fixed' | 'autoGrow';
|
|
10
|
+
export type NativeRichTextEditorToolbarPlacement = 'keyboard' | 'inline';
|
|
11
|
+
export interface RemoteSelectionDecoration {
|
|
12
|
+
clientId: number;
|
|
13
|
+
anchor: number;
|
|
14
|
+
head: number;
|
|
15
|
+
color: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
avatarUrl?: string;
|
|
18
|
+
isFocused?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface LinkRequestContext {
|
|
21
|
+
href?: string;
|
|
22
|
+
isActive: boolean;
|
|
23
|
+
selection: Selection;
|
|
24
|
+
setLink: (href: string) => void;
|
|
25
|
+
unsetLink: () => void;
|
|
26
|
+
}
|
|
27
|
+
export interface ImageRequestContext {
|
|
28
|
+
selection: Selection;
|
|
29
|
+
allowBase64: boolean;
|
|
30
|
+
insertImage: (src: string, attrs?: Omit<ImageNodeAttributes, 'src'>) => void;
|
|
31
|
+
}
|
|
32
|
+
export interface NativeRichTextEditorProps {
|
|
33
|
+
/** Initial content as HTML (uncontrolled mode). */
|
|
34
|
+
initialContent?: string;
|
|
35
|
+
/** Initial content as ProseMirror JSON (uncontrolled mode). */
|
|
36
|
+
initialJSON?: DocumentJSON;
|
|
37
|
+
/** Controlled HTML content. External changes are diffed and applied. */
|
|
38
|
+
value?: string;
|
|
39
|
+
/** Controlled ProseMirror JSON content. Ignored if value is set. */
|
|
40
|
+
valueJSON?: DocumentJSON;
|
|
41
|
+
/** Schema definition. Defaults to tiptapSchema if not provided. */
|
|
42
|
+
schema?: SchemaDefinition;
|
|
43
|
+
/** Placeholder text shown when editor is empty. */
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
/** Whether the editor is editable. */
|
|
46
|
+
editable?: boolean;
|
|
47
|
+
/** Maximum character length. */
|
|
48
|
+
maxLength?: number;
|
|
49
|
+
/** Whether to auto-focus on mount. */
|
|
50
|
+
autoFocus?: boolean;
|
|
51
|
+
/** Controls whether the editor scrolls internally or grows with content. */
|
|
52
|
+
heightBehavior?: NativeRichTextEditorHeightBehavior;
|
|
53
|
+
/** Whether to show the formatting toolbar. Defaults to true. */
|
|
54
|
+
showToolbar?: boolean;
|
|
55
|
+
/** Whether the toolbar is attached to the keyboard natively or rendered inline in React. */
|
|
56
|
+
toolbarPlacement?: NativeRichTextEditorToolbarPlacement;
|
|
57
|
+
/** Displayed toolbar buttons, in order. Supports custom marks/nodes. */
|
|
58
|
+
toolbarItems?: readonly EditorToolbarItem[];
|
|
59
|
+
/** Called when a custom `action` toolbar item is pressed. */
|
|
60
|
+
onToolbarAction?: (key: string) => void;
|
|
61
|
+
/** Called when a toolbar link item is pressed so the host can collect/edit a URL. */
|
|
62
|
+
onRequestLink?: (context: LinkRequestContext) => void;
|
|
63
|
+
/** Called when a toolbar image item is pressed so the host can choose an image source. */
|
|
64
|
+
onRequestImage?: (context: ImageRequestContext) => void;
|
|
65
|
+
/** Whether `data:image/...` sources are accepted for image insertion and HTML parsing. */
|
|
66
|
+
allowBase64Images?: boolean;
|
|
67
|
+
/** Whether selected images show native resize handles. */
|
|
68
|
+
allowImageResizing?: boolean;
|
|
69
|
+
/** Called when content changes with the current HTML. */
|
|
70
|
+
onContentChange?: (html: string) => void;
|
|
71
|
+
/** Called when content changes with the current ProseMirror JSON. */
|
|
72
|
+
onContentChangeJSON?: (json: DocumentJSON) => void;
|
|
73
|
+
/** Called when selection changes. */
|
|
74
|
+
onSelectionChange?: (selection: Selection) => void;
|
|
75
|
+
/** Called when active formatting state changes. */
|
|
76
|
+
onActiveStateChange?: (state: ActiveState) => void;
|
|
77
|
+
/** Called when undo/redo availability changes. */
|
|
78
|
+
onHistoryStateChange?: (state: HistoryState) => void;
|
|
79
|
+
/** Called when the editor gains focus. */
|
|
80
|
+
onFocus?: () => void;
|
|
81
|
+
/** Called when the editor loses focus. */
|
|
82
|
+
onBlur?: () => void;
|
|
83
|
+
/** Style applied to the native editor view. */
|
|
84
|
+
style?: StyleProp<ViewStyle>;
|
|
85
|
+
/** Style applied to the outer React container wrapping the editor and inline toolbar. */
|
|
86
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
87
|
+
/** Optional native content theme applied to rendered blocks and typing attrs. */
|
|
88
|
+
theme?: EditorTheme;
|
|
89
|
+
/** Optional addon configuration. */
|
|
90
|
+
addons?: EditorAddons;
|
|
91
|
+
/** Remote awareness selections rendered as native overlays. */
|
|
92
|
+
remoteSelections?: readonly RemoteSelectionDecoration[];
|
|
93
|
+
}
|
|
94
|
+
export interface NativeRichTextEditorRef {
|
|
95
|
+
/** Programmatically focus the editor. */
|
|
96
|
+
focus(): void;
|
|
97
|
+
/** Programmatically blur the editor. */
|
|
98
|
+
blur(): void;
|
|
99
|
+
/** Toggle a formatting mark (e.g. 'bold', 'italic'). */
|
|
100
|
+
toggleMark(markType: string): void;
|
|
101
|
+
/** Apply or update a hyperlink on the current selection. */
|
|
102
|
+
setLink(href: string): void;
|
|
103
|
+
/** Remove a hyperlink from the current selection. */
|
|
104
|
+
unsetLink(): void;
|
|
105
|
+
/** Toggle blockquote wrapping around the current block selection. */
|
|
106
|
+
toggleBlockquote(): void;
|
|
107
|
+
/** Toggle a list type (bulletList or orderedList). */
|
|
108
|
+
toggleList(listType: 'bulletList' | 'orderedList'): void;
|
|
109
|
+
/** Indent the current list item. */
|
|
110
|
+
indentListItem(): void;
|
|
111
|
+
/** Outdent the current list item. */
|
|
112
|
+
outdentListItem(): void;
|
|
113
|
+
/** Insert a void node (e.g. 'horizontalRule'). */
|
|
114
|
+
insertNode(nodeType: string): void;
|
|
115
|
+
/** Insert a block image node with the given source and optional metadata. */
|
|
116
|
+
insertImage(src: string, attrs?: Omit<ImageNodeAttributes, 'src'>): void;
|
|
117
|
+
/** Insert text at the current cursor position. */
|
|
118
|
+
insertText(text: string): void;
|
|
119
|
+
/** Insert HTML content at the current selection. */
|
|
120
|
+
insertContentHtml(html: string): void;
|
|
121
|
+
/** Insert JSON content at the current selection. */
|
|
122
|
+
insertContentJson(doc: DocumentJSON): void;
|
|
123
|
+
/** Replace entire document with HTML (preserves undo history). */
|
|
124
|
+
setContent(html: string): void;
|
|
125
|
+
/** Replace entire document with JSON (preserves undo history). */
|
|
126
|
+
setContentJson(doc: DocumentJSON): void;
|
|
127
|
+
/** Get the current HTML content. */
|
|
128
|
+
getContent(): string;
|
|
129
|
+
/** Get the current content as ProseMirror JSON. */
|
|
130
|
+
getContentJson(): DocumentJSON;
|
|
131
|
+
/** Get the plain text content (no markup). */
|
|
132
|
+
getTextContent(): string;
|
|
133
|
+
/** Undo the last operation. */
|
|
134
|
+
undo(): void;
|
|
135
|
+
/** Redo the last undone operation. */
|
|
136
|
+
redo(): void;
|
|
137
|
+
/** Check if undo is available. */
|
|
138
|
+
canUndo(): boolean;
|
|
139
|
+
/** Check if redo is available. */
|
|
140
|
+
canRedo(): boolean;
|
|
141
|
+
}
|
|
142
|
+
export declare const NativeRichTextEditor: React.ForwardRefExoticComponent<NativeRichTextEditorProps & React.RefAttributes<NativeRichTextEditorRef>>;
|