@openeditor/react-native-prose-editor 0.0.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/LICENSE +160 -0
- package/README.md +180 -0
- package/android/build.gradle +69 -0
- package/android/consumer-rules.pro +18 -0
- package/android/src/androidTest/AndroidManifest.xml +8 -0
- package/android/src/androidTest/java/com/apollohg/editor/MeasureHeightInstrumentedTest.kt +53 -0
- package/android/src/androidTest/java/com/apollohg/editor/NativeDeviceCollaborationInitialSyncTest.kt +241 -0
- package/android/src/androidTest/java/com/apollohg/editor/NativeDeviceImeRegressionTest.kt +338 -0
- package/android/src/androidTest/java/com/apollohg/editor/NativeDeviceOutsideTapTest.kt +789 -0
- package/android/src/androidTest/java/com/apollohg/editor/NativeDevicePerformanceTest.kt +350 -0
- package/android/src/androidTest/java/com/apollohg/editor/NativeEditorOutsideTapActivity.kt +5 -0
- package/android/src/main/assets/editor-icons/MaterialIcons.json +2236 -0
- package/android/src/main/assets/editor-icons/MaterialIcons.ttf +0 -0
- package/android/src/main/java/com/apollohg/editor/CaretGeometry.kt +50 -0
- package/android/src/main/java/com/apollohg/editor/EditorAddons.kt +135 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +4527 -0
- package/android/src/main/java/com/apollohg/editor/EditorHeightBehavior.kt +14 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputConnection.kt +999 -0
- package/android/src/main/java/com/apollohg/editor/EditorTheme.kt +474 -0
- package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +199 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +3137 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +561 -0
- package/android/src/main/java/com/apollohg/editor/NativeProseViewerExpoView.kt +315 -0
- package/android/src/main/java/com/apollohg/editor/NativeToolbar.kt +1413 -0
- package/android/src/main/java/com/apollohg/editor/PositionBridge.kt +133 -0
- package/android/src/main/java/com/apollohg/editor/RemoteSelectionOverlayView.kt +315 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridge.kt +2172 -0
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +399 -0
- package/android/src/sharedTest/java/com/apollohg/editor/NativePerformanceSupport.kt +482 -0
- package/android/src/test/java/com/apollohg/editor/CaretGeometryTest.kt +137 -0
- package/android/src/test/java/com/apollohg/editor/EditorEditTextHardwareKeyTest.kt +321 -0
- package/android/src/test/java/com/apollohg/editor/EditorInputConnectionTest.kt +4202 -0
- package/android/src/test/java/com/apollohg/editor/NativeEditorExpoViewTest.kt +2581 -0
- package/android/src/test/java/com/apollohg/editor/NativeEditorModuleTest.kt +27 -0
- package/android/src/test/java/com/apollohg/editor/NativePerformanceTest.kt +197 -0
- package/android/src/test/java/com/apollohg/editor/NativeProseViewerExpoViewTest.kt +84 -0
- package/android/src/test/java/com/apollohg/editor/NativeToolbarTest.kt +544 -0
- package/android/src/test/java/com/apollohg/editor/PositionBridgeTest.kt +461 -0
- package/android/src/test/java/com/apollohg/editor/RenderBridgeTest.kt +2054 -0
- package/android/src/test/java/com/apollohg/editor/RichTextEditorViewTest.kt +1367 -0
- package/app.plugin.js +62 -0
- package/dist/EditorTheme.d.ts +113 -0
- package/dist/EditorTheme.js +29 -0
- package/dist/EditorToolbar.d.ts +191 -0
- package/dist/EditorToolbar.js +1095 -0
- package/dist/NativeEditorBridge.d.ts +325 -0
- package/dist/NativeEditorBridge.js +933 -0
- package/dist/NativeProseViewer.d.ts +53 -0
- package/dist/NativeProseViewer.js +480 -0
- package/dist/NativeRichTextEditor.d.ts +183 -0
- package/dist/NativeRichTextEditor.js +2574 -0
- package/dist/YjsCollaboration.d.ts +90 -0
- package/dist/YjsCollaboration.js +743 -0
- package/dist/addons.d.ts +100 -0
- package/dist/addons.js +82 -0
- package/dist/heightCache.d.ts +6 -0
- package/dist/heightCache.js +45 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +30 -0
- package/dist/schemas.d.ts +37 -0
- package/dist/schemas.js +263 -0
- package/dist/useNativeEditor.d.ts +42 -0
- package/dist/useNativeEditor.js +124 -0
- package/expo-module.config.json +9 -0
- package/ios/EditorAddons.swift +327 -0
- package/ios/EditorCore.xcframework/Info.plist +44 -0
- 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 +774 -0
- package/ios/EditorTheme.swift +515 -0
- package/ios/Generated_editor_core.swift +1513 -0
- package/ios/NativeEditorExpoView.swift +3593 -0
- package/ios/NativeEditorModule.swift +624 -0
- package/ios/NativeProseViewerExpoView.swift +276 -0
- package/ios/PositionBridge.swift +558 -0
- package/ios/ReactNativeProseEditor.podspec +49 -0
- package/ios/RenderBridge.swift +1708 -0
- package/ios/RichTextEditorView.swift +6150 -0
- package/ios/Tests/NativePerformanceTests.swift +687 -0
- package/ios/Tests/PositionBridgeTests.swift +706 -0
- package/ios/Tests/RenderBridgeTests.swift +2236 -0
- package/ios/Tests/RichTextEditorViewTests.swift +6548 -0
- package/ios/editor_coreFFI/editor_coreFFI.h +1289 -0
- package/ios/editor_coreFFI/module.modulemap +7 -0
- package/ios/editor_coreFFI.h +904 -0
- package/ios/editor_coreFFI.modulemap +7 -0
- package/package.json +74 -0
- 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 +2563 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import type { EditorMentionTheme } from './EditorTheme';
|
|
2
|
+
import { type SchemaDefinition } from './schemas';
|
|
3
|
+
export interface NativeEditorModule {
|
|
4
|
+
editorCreate(configJson: string): number;
|
|
5
|
+
editorDestroy(editorId: number): void;
|
|
6
|
+
editorPrepareForCommand?(editorId: number): string;
|
|
7
|
+
collaborationSessionCreate(configJson: string): number;
|
|
8
|
+
collaborationSessionDestroy(sessionId: number): void;
|
|
9
|
+
collaborationSessionGetDocumentJson(sessionId: number): string;
|
|
10
|
+
collaborationSessionGetEncodedState(sessionId: number): string;
|
|
11
|
+
collaborationSessionGetPeersJson(sessionId: number): string;
|
|
12
|
+
collaborationSessionStart(sessionId: number): string;
|
|
13
|
+
collaborationSessionApplyLocalDocumentJson(sessionId: number, json: string): string;
|
|
14
|
+
collaborationSessionApplyEncodedState(sessionId: number, encodedStateJson: string): string;
|
|
15
|
+
collaborationSessionReplaceEncodedState(sessionId: number, encodedStateJson: string): string;
|
|
16
|
+
collaborationSessionHandleMessage(sessionId: number, messageJson: string): string;
|
|
17
|
+
collaborationSessionSetLocalAwareness(sessionId: number, awarenessJson: string): string;
|
|
18
|
+
collaborationSessionClearLocalAwareness(sessionId: number): string;
|
|
19
|
+
editorSetHtml(editorId: number, html: string): string;
|
|
20
|
+
editorGetHtml(editorId: number): string;
|
|
21
|
+
editorSetJson(editorId: number, json: string): string;
|
|
22
|
+
editorGetJson(editorId: number): string;
|
|
23
|
+
editorGetContentSnapshot(editorId: number): string;
|
|
24
|
+
editorReplaceHtml(editorId: number, html: string): string;
|
|
25
|
+
editorReplaceJson(editorId: number, json: string): string;
|
|
26
|
+
editorInsertText(editorId: number, pos: number, text: string): string;
|
|
27
|
+
editorReplaceSelectionText(editorId: number, text: string): string;
|
|
28
|
+
editorDeleteRange(editorId: number, from: number, to: number): string;
|
|
29
|
+
editorSplitBlock(editorId: number, pos: number): string;
|
|
30
|
+
editorInsertContentHtml(editorId: number, html: string): string;
|
|
31
|
+
editorInsertContentJson(editorId: number, json: string): string;
|
|
32
|
+
editorInsertContentJsonAtSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number, json: string): string;
|
|
33
|
+
editorToggleMark(editorId: number, markName: string): string;
|
|
34
|
+
editorSetMark(editorId: number, markName: string, attrsJson: string): string;
|
|
35
|
+
editorUnsetMark(editorId: number, markName: string): string;
|
|
36
|
+
editorToggleBlockquote(editorId: number): string;
|
|
37
|
+
editorToggleHeading(editorId: number, level: number): string;
|
|
38
|
+
editorSetSelection(editorId: number, anchor: number, head: number): void;
|
|
39
|
+
editorGetSelection(editorId: number): string;
|
|
40
|
+
editorGetSelectionState(editorId: number): string;
|
|
41
|
+
editorGetCurrentState(editorId: number): string;
|
|
42
|
+
editorInsertTextScalar(editorId: number, scalarPos: number, text: string): string;
|
|
43
|
+
editorDeleteScalarRange(editorId: number, scalarFrom: number, scalarTo: number): string;
|
|
44
|
+
editorReplaceTextScalar(editorId: number, scalarFrom: number, scalarTo: number, text: string): string;
|
|
45
|
+
editorSplitBlockScalar(editorId: number, scalarPos: number): string;
|
|
46
|
+
editorDeleteAndSplitScalar(editorId: number, scalarFrom: number, scalarTo: number): string;
|
|
47
|
+
editorSetSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number): void;
|
|
48
|
+
editorToggleMarkAtSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number, markName: string): string;
|
|
49
|
+
editorSetMarkAtSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number, markName: string, attrsJson: string): string;
|
|
50
|
+
editorUnsetMarkAtSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number, markName: string): string;
|
|
51
|
+
editorToggleBlockquoteAtSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number): string;
|
|
52
|
+
editorToggleHeadingAtSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number, level: number): string;
|
|
53
|
+
editorWrapInListAtSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number, listType: string): string;
|
|
54
|
+
editorUnwrapFromListAtSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number): string;
|
|
55
|
+
editorIndentListItemAtSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number): string;
|
|
56
|
+
editorOutdentListItemAtSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number): string;
|
|
57
|
+
editorInsertNodeAtSelectionScalar(editorId: number, scalarAnchor: number, scalarHead: number, nodeType: string): string;
|
|
58
|
+
editorDocToScalar(editorId: number, docPos: number): number;
|
|
59
|
+
editorScalarToDoc(editorId: number, scalar: number): number;
|
|
60
|
+
editorWrapInList(editorId: number, listType: string): string;
|
|
61
|
+
editorUnwrapFromList(editorId: number): string;
|
|
62
|
+
editorIndentListItem(editorId: number): string;
|
|
63
|
+
editorOutdentListItem(editorId: number): string;
|
|
64
|
+
editorInsertNode(editorId: number, nodeType: string): string;
|
|
65
|
+
editorUndo(editorId: number): string;
|
|
66
|
+
editorRedo(editorId: number): string;
|
|
67
|
+
editorCanUndo(editorId: number): boolean;
|
|
68
|
+
editorCanRedo(editorId: number): boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface Selection {
|
|
71
|
+
type: 'text' | 'node' | 'all';
|
|
72
|
+
anchor?: number;
|
|
73
|
+
head?: number;
|
|
74
|
+
pos?: number;
|
|
75
|
+
}
|
|
76
|
+
export interface ListContext {
|
|
77
|
+
ordered: boolean;
|
|
78
|
+
index: number;
|
|
79
|
+
total: number;
|
|
80
|
+
start: number;
|
|
81
|
+
isFirst: boolean;
|
|
82
|
+
isLast: boolean;
|
|
83
|
+
kind?: string | null;
|
|
84
|
+
checked?: boolean | null;
|
|
85
|
+
}
|
|
86
|
+
export interface RenderMarkWithAttrs {
|
|
87
|
+
type: string;
|
|
88
|
+
[key: string]: unknown;
|
|
89
|
+
}
|
|
90
|
+
export type RenderMark = string | RenderMarkWithAttrs;
|
|
91
|
+
export interface RenderElement {
|
|
92
|
+
type: 'textRun' | 'blockStart' | 'blockEnd' | 'voidInline' | 'voidBlock' | 'opaqueInlineAtom' | 'opaqueBlockAtom';
|
|
93
|
+
text?: string;
|
|
94
|
+
marks?: RenderMark[];
|
|
95
|
+
nodeType?: string;
|
|
96
|
+
depth?: number;
|
|
97
|
+
docPos?: number;
|
|
98
|
+
label?: string;
|
|
99
|
+
attrs?: Record<string, unknown>;
|
|
100
|
+
mentionTheme?: EditorMentionTheme;
|
|
101
|
+
listContext?: ListContext;
|
|
102
|
+
}
|
|
103
|
+
interface RenderBlocksPatch {
|
|
104
|
+
startIndex: number;
|
|
105
|
+
deleteCount: number;
|
|
106
|
+
renderBlocks: RenderElement[][];
|
|
107
|
+
}
|
|
108
|
+
export interface ActiveState {
|
|
109
|
+
marks: Record<string, boolean>;
|
|
110
|
+
markAttrs: Record<string, Record<string, unknown>>;
|
|
111
|
+
nodes: Record<string, boolean>;
|
|
112
|
+
commands: Record<string, boolean>;
|
|
113
|
+
allowedMarks: string[];
|
|
114
|
+
insertableNodes: string[];
|
|
115
|
+
}
|
|
116
|
+
export interface HistoryState {
|
|
117
|
+
canUndo: boolean;
|
|
118
|
+
canRedo: boolean;
|
|
119
|
+
}
|
|
120
|
+
export interface EditorUpdate {
|
|
121
|
+
renderElements: RenderElement[];
|
|
122
|
+
renderBlocks?: RenderElement[][];
|
|
123
|
+
renderPatch?: RenderBlocksPatch;
|
|
124
|
+
selection: Selection;
|
|
125
|
+
activeState: ActiveState;
|
|
126
|
+
historyState: HistoryState;
|
|
127
|
+
documentVersion?: number;
|
|
128
|
+
}
|
|
129
|
+
export interface ParseUpdateOptions {
|
|
130
|
+
rejectSameDocumentVersion?: boolean;
|
|
131
|
+
rejectVersionlessAfterDocumentVersion?: boolean;
|
|
132
|
+
}
|
|
133
|
+
export interface ContentSnapshot {
|
|
134
|
+
html: string;
|
|
135
|
+
json: DocumentJSON;
|
|
136
|
+
}
|
|
137
|
+
export interface DocumentJSON {
|
|
138
|
+
[key: string]: unknown;
|
|
139
|
+
}
|
|
140
|
+
export interface CollaborationPeer {
|
|
141
|
+
clientId: number;
|
|
142
|
+
isLocal: boolean;
|
|
143
|
+
state: Record<string, unknown> | null;
|
|
144
|
+
}
|
|
145
|
+
export interface CollaborationResult {
|
|
146
|
+
messages: number[][];
|
|
147
|
+
documentChanged: boolean;
|
|
148
|
+
documentJson?: DocumentJSON;
|
|
149
|
+
peersChanged: boolean;
|
|
150
|
+
peers?: CollaborationPeer[];
|
|
151
|
+
}
|
|
152
|
+
export type CommandBlockedReason = 'composition' | 'detached' | 'pendingUpdate' | 'destroyed' | 'unknown';
|
|
153
|
+
export interface CommandBlockedInfo {
|
|
154
|
+
blocked: boolean;
|
|
155
|
+
reason: CommandBlockedReason | null;
|
|
156
|
+
}
|
|
157
|
+
export type EncodedCollaborationStateInput = Uint8Array | readonly number[] | string;
|
|
158
|
+
export declare function normalizeActiveState(raw: unknown): ActiveState;
|
|
159
|
+
export declare function parseEditorUpdateJson(json: string, previousRenderBlocks?: RenderElement[][]): EditorUpdate | null;
|
|
160
|
+
export declare function encodeCollaborationStateBase64(encodedState: EncodedCollaborationStateInput): string;
|
|
161
|
+
export declare function decodeCollaborationStateBase64(base64: string): Uint8Array;
|
|
162
|
+
export declare function parseCollaborationResultJson(json: string): CollaborationResult;
|
|
163
|
+
/** @internal Reset the cached native module reference. For testing only. */
|
|
164
|
+
export declare function _resetNativeModuleCache(): void;
|
|
165
|
+
export declare class NativeEditorBridge {
|
|
166
|
+
private _editorId;
|
|
167
|
+
private _schema?;
|
|
168
|
+
private _destroyed;
|
|
169
|
+
private _lastSelection;
|
|
170
|
+
private _documentVersion;
|
|
171
|
+
private _cachedHtml;
|
|
172
|
+
private _cachedJsonString;
|
|
173
|
+
private _renderBlocksCache;
|
|
174
|
+
private _lastCommandBlocked;
|
|
175
|
+
private _lastCommandBlockedReason;
|
|
176
|
+
private _lastCommandPreflightUpdate;
|
|
177
|
+
private _lastAcceptedUpdateJson;
|
|
178
|
+
private _hasSeenDocumentVersion;
|
|
179
|
+
private constructor();
|
|
180
|
+
/** Create a new editor instance backed by the Rust engine. */
|
|
181
|
+
static create(config?: {
|
|
182
|
+
maxLength?: number;
|
|
183
|
+
schemaJson?: string;
|
|
184
|
+
allowBase64Images?: boolean;
|
|
185
|
+
}): NativeEditorBridge;
|
|
186
|
+
/** The underlying native editor ID. */
|
|
187
|
+
get editorId(): number;
|
|
188
|
+
/** Whether this bridge has been destroyed. */
|
|
189
|
+
get isDestroyed(): boolean;
|
|
190
|
+
consumeLastCommandBlocked(): boolean;
|
|
191
|
+
consumeLastCommandBlockedReason(): CommandBlockedReason | null;
|
|
192
|
+
consumeLastCommandBlockedInfo(): CommandBlockedInfo;
|
|
193
|
+
consumeLastCommandPreflightUpdate(): EditorUpdate | null;
|
|
194
|
+
prepareForNativeCommand(): boolean;
|
|
195
|
+
/** Destroy the editor instance and free native resources. */
|
|
196
|
+
destroy(): void;
|
|
197
|
+
/** Set content from HTML. Returns render elements for display. */
|
|
198
|
+
setHtml(html: string): RenderElement[];
|
|
199
|
+
/** Get content as HTML. */
|
|
200
|
+
getHtml(): string;
|
|
201
|
+
/** Get cached HTML without making a native roundtrip. */
|
|
202
|
+
getCachedHtml(): string | null;
|
|
203
|
+
/** Set content from ProseMirror JSON. Returns render elements. */
|
|
204
|
+
setJson(doc: DocumentJSON): RenderElement[];
|
|
205
|
+
/** Set content from a serialized ProseMirror JSON string. Returns render elements. */
|
|
206
|
+
setJsonString(jsonString: string): RenderElement[];
|
|
207
|
+
/** Get content as raw ProseMirror JSON string. */
|
|
208
|
+
getJsonString(): string;
|
|
209
|
+
/** Get cached raw ProseMirror JSON without making a native roundtrip. */
|
|
210
|
+
getCachedJsonString(): string | null;
|
|
211
|
+
/** Get cached ProseMirror JSON without making a native roundtrip. */
|
|
212
|
+
getCachedJson(): DocumentJSON | null;
|
|
213
|
+
/** Get content as ProseMirror JSON. */
|
|
214
|
+
getJson(): DocumentJSON;
|
|
215
|
+
/** Get both HTML and JSON content in one native roundtrip. */
|
|
216
|
+
getContentSnapshot(): ContentSnapshot;
|
|
217
|
+
/** Insert text at a document position. Returns the full update. */
|
|
218
|
+
insertText(pos: number, text: string): EditorUpdate | null;
|
|
219
|
+
/** Delete a range [from, to). Returns the full update. */
|
|
220
|
+
deleteRange(from: number, to: number): EditorUpdate | null;
|
|
221
|
+
/** Replace the current selection with text atomically. */
|
|
222
|
+
replaceSelectionText(text: string): EditorUpdate | null;
|
|
223
|
+
/** Toggle a mark (bold, italic, etc.) on the current selection. */
|
|
224
|
+
toggleMark(markType: string): EditorUpdate | null;
|
|
225
|
+
/** Set a mark with attrs on the current selection. */
|
|
226
|
+
setMark(markType: string, attrs: Record<string, unknown>): EditorUpdate | null;
|
|
227
|
+
/** Set a mark with attrs at an explicit scalar selection. */
|
|
228
|
+
setMarkAtSelectionScalar(scalarAnchor: number, scalarHead: number, markType: string, attrs: Record<string, unknown>): EditorUpdate | null;
|
|
229
|
+
/** Remove a mark from the current selection. */
|
|
230
|
+
unsetMark(markType: string): EditorUpdate | null;
|
|
231
|
+
/** Remove a mark at an explicit scalar selection. */
|
|
232
|
+
unsetMarkAtSelectionScalar(scalarAnchor: number, scalarHead: number, markType: string): EditorUpdate | null;
|
|
233
|
+
/** Toggle blockquote wrapping for the current block selection. */
|
|
234
|
+
toggleBlockquote(): EditorUpdate | null;
|
|
235
|
+
/** Toggle a heading level on the current block selection. */
|
|
236
|
+
toggleHeading(level: number): EditorUpdate | null;
|
|
237
|
+
/** Set the document selection by anchor and head positions. */
|
|
238
|
+
setSelection(anchor: number, head: number): void;
|
|
239
|
+
/** Convert a document position to a scalar position used by native text views. */
|
|
240
|
+
docToScalar(docPos: number): number;
|
|
241
|
+
/** Convert a native scalar position back to a document position. */
|
|
242
|
+
scalarToDoc(scalar: number): number;
|
|
243
|
+
/** Get the current selection from the Rust engine (synchronous native call).
|
|
244
|
+
* Always returns the live selection, not a stale cache. */
|
|
245
|
+
getSelection(): Selection;
|
|
246
|
+
/** Update the cached selection from native events (scalar offsets).
|
|
247
|
+
* Called by the React component when native selection change events arrive. */
|
|
248
|
+
updateSelectionFromNative(anchor: number, head: number): void;
|
|
249
|
+
/** Get the current full state from Rust (render elements, selection, etc.). */
|
|
250
|
+
getCurrentState(): EditorUpdate | null;
|
|
251
|
+
/** Get the current selection-related state without render elements. */
|
|
252
|
+
getSelectionState(): EditorUpdate | null;
|
|
253
|
+
/** Split the block at a position (Enter key). */
|
|
254
|
+
splitBlock(pos: number): EditorUpdate | null;
|
|
255
|
+
/** Insert HTML content at the current selection. */
|
|
256
|
+
insertContentHtml(html: string): EditorUpdate | null;
|
|
257
|
+
/** Insert JSON content at the current selection. */
|
|
258
|
+
insertContentJson(doc: DocumentJSON): EditorUpdate | null;
|
|
259
|
+
/** Insert JSON content at an explicit scalar selection. */
|
|
260
|
+
insertContentJsonAtSelectionScalar(scalarAnchor: number, scalarHead: number, doc: DocumentJSON): EditorUpdate | null;
|
|
261
|
+
/** Insert lazily-built JSON content at an explicit scalar selection. */
|
|
262
|
+
insertContentJsonAtSelectionScalarLazy(scalarAnchor: number, scalarHead: number, resolveDoc: () => DocumentJSON): EditorUpdate | null;
|
|
263
|
+
/** Replace entire document with HTML via transaction (preserves undo history). */
|
|
264
|
+
replaceHtml(html: string): EditorUpdate | null;
|
|
265
|
+
/** Replace entire document with JSON via transaction (preserves undo history). */
|
|
266
|
+
replaceJson(doc: DocumentJSON): EditorUpdate | null;
|
|
267
|
+
/** Replace entire document with a serialized JSON transaction. */
|
|
268
|
+
replaceJsonString(jsonString: string): EditorUpdate | null;
|
|
269
|
+
/** Undo the last operation. Returns update or null if nothing to undo. */
|
|
270
|
+
undo(): EditorUpdate | null;
|
|
271
|
+
/** Redo the last undone operation. Returns update or null if nothing to redo. */
|
|
272
|
+
redo(): EditorUpdate | null;
|
|
273
|
+
/** Check if undo is available. */
|
|
274
|
+
canUndo(): boolean;
|
|
275
|
+
/** Check if redo is available. */
|
|
276
|
+
canRedo(): boolean;
|
|
277
|
+
/** Toggle a list type on the current selection. Wraps if not in list, unwraps if already in that list type. */
|
|
278
|
+
toggleList(listType: string): EditorUpdate | null;
|
|
279
|
+
/** Unwrap the current list item back to a paragraph. */
|
|
280
|
+
unwrapFromList(): EditorUpdate | null;
|
|
281
|
+
/** Indent the current list item into a nested list. */
|
|
282
|
+
indentListItem(): EditorUpdate | null;
|
|
283
|
+
/** Outdent the current list item to the parent list level. */
|
|
284
|
+
outdentListItem(): EditorUpdate | null;
|
|
285
|
+
/** Insert a void node (e.g. 'horizontalRule') at the current selection. */
|
|
286
|
+
insertNode(nodeType: string): EditorUpdate | null;
|
|
287
|
+
parseUpdateJson(json: string, options?: ParseUpdateOptions): EditorUpdate | null;
|
|
288
|
+
private noteUpdate;
|
|
289
|
+
private shouldRejectUpdate;
|
|
290
|
+
private parseAndNoteUpdate;
|
|
291
|
+
private prepareForCommand;
|
|
292
|
+
private runPreparedCommand;
|
|
293
|
+
private invalidateContentCaches;
|
|
294
|
+
private assertNotDestroyed;
|
|
295
|
+
private currentScalarSelection;
|
|
296
|
+
}
|
|
297
|
+
export declare class NativeCollaborationBridge {
|
|
298
|
+
private _sessionId;
|
|
299
|
+
private _destroyed;
|
|
300
|
+
private constructor();
|
|
301
|
+
static create(config?: {
|
|
302
|
+
clientId?: number;
|
|
303
|
+
fragmentName?: string;
|
|
304
|
+
schema?: SchemaDefinition;
|
|
305
|
+
initialDocumentJson?: DocumentJSON;
|
|
306
|
+
initialEncodedState?: EncodedCollaborationStateInput;
|
|
307
|
+
localAwareness?: Record<string, unknown>;
|
|
308
|
+
}): NativeCollaborationBridge;
|
|
309
|
+
get sessionId(): number;
|
|
310
|
+
get isDestroyed(): boolean;
|
|
311
|
+
destroy(): void;
|
|
312
|
+
getDocumentJson(): DocumentJSON;
|
|
313
|
+
getEncodedState(): Uint8Array;
|
|
314
|
+
getEncodedStateBase64(): string;
|
|
315
|
+
getPeers(): CollaborationPeer[];
|
|
316
|
+
start(): CollaborationResult;
|
|
317
|
+
applyLocalDocumentJson(doc: DocumentJSON): CollaborationResult;
|
|
318
|
+
applyEncodedState(encodedState: EncodedCollaborationStateInput): CollaborationResult;
|
|
319
|
+
replaceEncodedState(encodedState: EncodedCollaborationStateInput): CollaborationResult;
|
|
320
|
+
handleMessage(bytes: readonly number[]): CollaborationResult;
|
|
321
|
+
setLocalAwareness(state: Record<string, unknown>): CollaborationResult;
|
|
322
|
+
clearLocalAwareness(): CollaborationResult;
|
|
323
|
+
private assertNotDestroyed;
|
|
324
|
+
}
|
|
325
|
+
export {};
|