noteloom 0.1.7 → 0.2.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 +639 -438
- package/dist/index.d.ts +620 -0
- package/dist/noteloom.cjs +24 -12
- package/dist/noteloom.cjs.map +1 -1
- package/dist/noteloom.es.js +6995 -5937
- package/dist/noteloom.es.js.map +1 -1
- package/dist/style.css +16 -4
- package/package.json +26 -6
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
// Hand-written type declarations for noteloom's public API (src/index.js).
|
|
2
|
+
// Covers the primary surface in real detail (store/CRDT/sync/persistence,
|
|
3
|
+
// the React provider + core hooks, useEditor/NoteloomEditor, block/inline
|
|
4
|
+
// registries); the long tail of block-specific commands/components is
|
|
5
|
+
// typed more loosely (real parameter counts, permissive value types) so
|
|
6
|
+
// every export still gets *something* useful rather than `any`. No `.js`/
|
|
7
|
+
// `.jsx` source was changed to produce this file.
|
|
8
|
+
|
|
9
|
+
import type { ComponentType, ReactNode, ReactElement, CSSProperties, RefObject, ClipboardEvent } from 'react';
|
|
10
|
+
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Document shape
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
export interface Block {
|
|
16
|
+
id: string;
|
|
17
|
+
type: string;
|
|
18
|
+
parentId: string | null;
|
|
19
|
+
contentIds: string[];
|
|
20
|
+
props: Record<string, unknown>;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Run {
|
|
25
|
+
id: string;
|
|
26
|
+
type: string;
|
|
27
|
+
value?: string;
|
|
28
|
+
marks?: Record<string, unknown>;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface FieldType {
|
|
33
|
+
id: string;
|
|
34
|
+
label: string;
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
variant?: string;
|
|
37
|
+
options: Array<{ value: string; label: string; color?: string }>;
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface DocumentJSON {
|
|
42
|
+
rootId: string;
|
|
43
|
+
blocks: Block[];
|
|
44
|
+
runs: Run[];
|
|
45
|
+
fieldTypes?: FieldType[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type Operation = { type: string; [key: string]: unknown };
|
|
49
|
+
export type OperationInverse = Operation;
|
|
50
|
+
|
|
51
|
+
/** Opaque envelope shape carried between EditorStore.applyRemoteOperation and CollabSession/syncProtocol — kind-discriminated, see EditorStore.js. */
|
|
52
|
+
export type RemoteOperationEnvelope = { kind: string; [key: string]: unknown };
|
|
53
|
+
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// store/operations.js
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
export const OP: {
|
|
59
|
+
INSERT_BLOCK: 'insertBlock';
|
|
60
|
+
REMOVE_BLOCK: 'removeBlock';
|
|
61
|
+
MOVE_BLOCK: 'moveBlock';
|
|
62
|
+
CHANGE_BLOCK_TYPE: 'changeBlockType';
|
|
63
|
+
UPDATE_BLOCK_PROPS: 'updateBlockProps';
|
|
64
|
+
UPDATE_RUN: 'updateRun';
|
|
65
|
+
SET_BLOCK_CONTENT_IDS: 'setBlockContentIds';
|
|
66
|
+
REPLACE_RUN_SPAN: 'replaceRunSpan';
|
|
67
|
+
SET_BLOCK_RUNS: 'setBlockRuns';
|
|
68
|
+
ADD_FIELD_TYPE: 'addFieldType';
|
|
69
|
+
UPDATE_FIELD_TYPE: 'updateFieldType';
|
|
70
|
+
REMOVE_FIELD_TYPE: 'removeFieldType';
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export namespace operations {
|
|
74
|
+
export function insertBlock(block: Block, parentId: string, index: number, subtree?: { blocks: Block[]; runs: Run[] }): Operation;
|
|
75
|
+
export function removeBlock(id: string): Operation;
|
|
76
|
+
export function moveBlock(id: string, toParentId: string, toIndex: number): Operation;
|
|
77
|
+
export function updateBlockProps(id: string, patch: Record<string, unknown>): Operation;
|
|
78
|
+
export function changeBlockType(id: string, blockType: string, props: Record<string, unknown>): Operation;
|
|
79
|
+
export function updateRun(id: string, patch: Record<string, unknown>): Operation;
|
|
80
|
+
export function setBlockContentIds(blockId: string, contentIds: string[]): Operation;
|
|
81
|
+
export function replaceRunSpan(blockId: string, oldRunIds: string[], newRuns: Run[]): Operation;
|
|
82
|
+
export function setBlockRuns(blockId: string, runs: Run[]): Operation;
|
|
83
|
+
export function addFieldType(fieldType: FieldType): Operation;
|
|
84
|
+
export function updateFieldType(id: string, patch: Partial<FieldType>): Operation;
|
|
85
|
+
export function removeFieldType(id: string): Operation;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// store/EditorStore.js, store/history.js
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
export class EditorStore {
|
|
93
|
+
constructor(doc?: DocumentJSON);
|
|
94
|
+
blocks: Map<string, Block>;
|
|
95
|
+
runs: Map<string, Run>;
|
|
96
|
+
rootId: string | null;
|
|
97
|
+
fieldTypes: Map<string, FieldType>;
|
|
98
|
+
|
|
99
|
+
getBlock(id: string): Block | undefined;
|
|
100
|
+
getRun(id: string): Run | undefined;
|
|
101
|
+
getFieldTypes(): FieldType[];
|
|
102
|
+
getFieldType(id: string): FieldType | undefined;
|
|
103
|
+
getRootId(): string | null;
|
|
104
|
+
subscribe(id: string, listener: () => void): () => void;
|
|
105
|
+
subscribeAll(listener: () => void): () => void;
|
|
106
|
+
applyOperation(op: Operation): OperationInverse;
|
|
107
|
+
applyOperations(ops: Operation[]): OperationInverse[];
|
|
108
|
+
getLastEnvelope(): RemoteOperationEnvelope | null;
|
|
109
|
+
applyRemoteOperation(envelope: RemoteOperationEnvelope): void;
|
|
110
|
+
getTombstoneCount(): number;
|
|
111
|
+
pruneTombstones(options?: { maxAgeMs?: number; now?: number }): number;
|
|
112
|
+
toJSON(): DocumentJSON;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface HistoryOptions {
|
|
116
|
+
idleMs?: number;
|
|
117
|
+
trackChanges?: boolean;
|
|
118
|
+
maxChangeLogSize?: number;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface HistoryLogEntry {
|
|
122
|
+
opType: string;
|
|
123
|
+
id: string | undefined;
|
|
124
|
+
actorId: string | null;
|
|
125
|
+
timestamp: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface ChangeLogEntry extends HistoryLogEntry {
|
|
129
|
+
before?: unknown;
|
|
130
|
+
after?: unknown;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface OperationMeta {
|
|
134
|
+
actorId?: string | null;
|
|
135
|
+
timestamp?: number;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Wraps an EditorStore with undo/redo — exposes the same read surface, so anything typed against `EditorStore` also accepts a `History` instance. */
|
|
139
|
+
export class History {
|
|
140
|
+
constructor(store: EditorStore, options?: HistoryOptions);
|
|
141
|
+
store: EditorStore;
|
|
142
|
+
|
|
143
|
+
getBlock(id: string): Block | undefined;
|
|
144
|
+
getRun(id: string): Run | undefined;
|
|
145
|
+
getRootId(): string | null;
|
|
146
|
+
getFieldTypes(): FieldType[];
|
|
147
|
+
getFieldType(id: string): FieldType | undefined;
|
|
148
|
+
subscribe(id: string, listener: () => void): () => void;
|
|
149
|
+
subscribeAll(listener: () => void): () => void;
|
|
150
|
+
getTombstoneCount(): number;
|
|
151
|
+
pruneTombstones(options?: { maxAgeMs?: number; now?: number }): number;
|
|
152
|
+
toJSON(): DocumentJSON;
|
|
153
|
+
|
|
154
|
+
applyOperation(op: Operation, meta?: OperationMeta): OperationInverse;
|
|
155
|
+
applyOperations(ops: Operation[], meta?: OperationMeta): OperationInverse[];
|
|
156
|
+
performBatch(ops: Operation[], meta?: OperationMeta): void;
|
|
157
|
+
perform(op: Operation, meta?: OperationMeta): OperationInverse;
|
|
158
|
+
flush(): void;
|
|
159
|
+
undo(): boolean;
|
|
160
|
+
redo(): boolean;
|
|
161
|
+
canUndo(): boolean;
|
|
162
|
+
canRedo(): boolean;
|
|
163
|
+
getPendingSelection(): { runId: string; offset: number } | null;
|
|
164
|
+
getPendingAffectedBlockIds(): string[];
|
|
165
|
+
getUndoRedoSnapshot(): { canUndo: boolean; canRedo: boolean };
|
|
166
|
+
getHistoryLog(): HistoryLogEntry[];
|
|
167
|
+
getChangeLog(): ChangeLogEntry[];
|
|
168
|
+
subscribeToHistory(listener: () => void): () => void;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
// crdt/
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
|
|
175
|
+
export interface HlcTimestamp {
|
|
176
|
+
physical: number;
|
|
177
|
+
logical: number;
|
|
178
|
+
peerId: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export class HLC {
|
|
182
|
+
constructor(peerId: string);
|
|
183
|
+
tick(): HlcTimestamp;
|
|
184
|
+
receive(remote: HlcTimestamp): HlcTimestamp;
|
|
185
|
+
static compare(a: HlcTimestamp, b: HlcTimestamp): number;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function genPeerId(): string;
|
|
189
|
+
|
|
190
|
+
export interface ListCrdtSlot {
|
|
191
|
+
id: string;
|
|
192
|
+
originId: string | null;
|
|
193
|
+
clock: HlcTimestamp;
|
|
194
|
+
deletedClock?: HlcTimestamp | null;
|
|
195
|
+
[key: string]: unknown;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export class ListCrdtState {
|
|
199
|
+
static fromArray(ids: string[], options?: { peerId?: string }): ListCrdtState;
|
|
200
|
+
has(id: string): boolean;
|
|
201
|
+
getSlot(id: string): ListCrdtSlot | undefined;
|
|
202
|
+
isDeleted(id: string): boolean;
|
|
203
|
+
insert(id: string, afterId: string | null, clock: HlcTimestamp, peerId: string): ListCrdtSlot;
|
|
204
|
+
delete(id: string, clock: HlcTimestamp): void;
|
|
205
|
+
restore(id: string): void;
|
|
206
|
+
move(id: string, afterId: string | null, clock: HlcTimestamp, peerId: string): void;
|
|
207
|
+
merge(remoteSlots: ListCrdtSlot[]): void;
|
|
208
|
+
toSlotArray(): ListCrdtSlot[];
|
|
209
|
+
toArray(): string[];
|
|
210
|
+
tombstoneCount(): number;
|
|
211
|
+
pruneTombstones(beforeClock: HlcTimestamp): number;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export class FieldClockRegistry {
|
|
215
|
+
shouldApply(key: string, clock: HlcTimestamp): boolean;
|
|
216
|
+
record(key: string, clock: HlcTimestamp): void;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function createPeriodicTombstoneGC(options: {
|
|
220
|
+
store: EditorStore | History;
|
|
221
|
+
intervalMs?: number;
|
|
222
|
+
maxAgeMs?: number;
|
|
223
|
+
onPrune?: (prunedCount: number) => void;
|
|
224
|
+
onError?: (error: unknown) => void;
|
|
225
|
+
}): { stop: () => void };
|
|
226
|
+
|
|
227
|
+
// ---------------------------------------------------------------------------
|
|
228
|
+
// sync/
|
|
229
|
+
// ---------------------------------------------------------------------------
|
|
230
|
+
|
|
231
|
+
export interface SignalingChannel {
|
|
232
|
+
send(message: unknown): void;
|
|
233
|
+
onMessage(handler: (message: unknown) => void): () => void;
|
|
234
|
+
close(): void;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export const MESSAGE_TYPE: {
|
|
238
|
+
HELLO: string;
|
|
239
|
+
OP: string;
|
|
240
|
+
SYNC_REQUEST: string;
|
|
241
|
+
SYNC_RESPONSE: string;
|
|
242
|
+
PRESENCE: string;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export function encodeMessage(message: unknown): string;
|
|
246
|
+
export function decodeMessage(raw: string): unknown;
|
|
247
|
+
|
|
248
|
+
export class PeerConnection {
|
|
249
|
+
constructor(options: { peerConnection: RTCPeerConnection; dataChannel?: RTCDataChannel; onMessage?: (message: unknown) => void });
|
|
250
|
+
send(message: unknown): void;
|
|
251
|
+
close(): void;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export class CollabSession {
|
|
255
|
+
constructor(options: { history: History | EditorStore; signaling: SignalingChannel; presenceThrottleMs?: number });
|
|
256
|
+
connect(remotePeerId: string, options: { initiator: boolean }): void;
|
|
257
|
+
disconnect(remotePeerId: string): void;
|
|
258
|
+
destroy(): void;
|
|
259
|
+
setLocalPresence(data: Record<string, unknown>): void;
|
|
260
|
+
getPresence(): Map<string, Record<string, unknown>>;
|
|
261
|
+
onPresenceChange(callback: (presence: Map<string, Record<string, unknown>>) => void): () => void;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function createWebSocketSignaling(options: {
|
|
265
|
+
url: string;
|
|
266
|
+
roomId: string;
|
|
267
|
+
peerId: string;
|
|
268
|
+
WebSocketImpl?: typeof WebSocket;
|
|
269
|
+
}): SignalingChannel;
|
|
270
|
+
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
// persistence/
|
|
273
|
+
// ---------------------------------------------------------------------------
|
|
274
|
+
|
|
275
|
+
export function savePersistedDocument(docId: string, doc: DocumentJSON): Promise<void>;
|
|
276
|
+
export function loadPersistedDocument(docId: string): Promise<DocumentJSON | undefined>;
|
|
277
|
+
export function deletePersistedDocument(docId: string): Promise<void>;
|
|
278
|
+
export function listPersistedDocumentIds(): Promise<string[]>;
|
|
279
|
+
|
|
280
|
+
export function createAutoPersistence(options: {
|
|
281
|
+
store: History | EditorStore;
|
|
282
|
+
docId: string;
|
|
283
|
+
debounceMs?: number;
|
|
284
|
+
onError?: (error: unknown) => void;
|
|
285
|
+
}): { stop: () => void; flush: () => void };
|
|
286
|
+
|
|
287
|
+
// ---------------------------------------------------------------------------
|
|
288
|
+
// registry/, blocks/, inlineTypes/
|
|
289
|
+
// ---------------------------------------------------------------------------
|
|
290
|
+
|
|
291
|
+
export interface BlockTypeEntry {
|
|
292
|
+
component: ComponentType<{ id: string }>;
|
|
293
|
+
isLeaf: boolean;
|
|
294
|
+
defaultProps?: Record<string, unknown>;
|
|
295
|
+
[key: string]: unknown;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export class BlockRegistry {
|
|
299
|
+
register(type: string, entry: BlockTypeEntry): void;
|
|
300
|
+
get(type: string): BlockTypeEntry | undefined;
|
|
301
|
+
isLeaf(type: string): boolean;
|
|
302
|
+
listSlashCommands(): unknown[];
|
|
303
|
+
listHtmlMatchers(): BlockTypeEntry[];
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export function createBlockRegistry(): BlockRegistry;
|
|
307
|
+
|
|
308
|
+
export interface InlineTypeEntry {
|
|
309
|
+
component: ComponentType<{ id: string }>;
|
|
310
|
+
isAtomic: true;
|
|
311
|
+
[key: string]: unknown;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export class InlineRegistry {
|
|
315
|
+
register(type: string, entry: InlineTypeEntry): void;
|
|
316
|
+
unregister(type: string): void;
|
|
317
|
+
get(type: string): InlineTypeEntry | undefined;
|
|
318
|
+
listHtmlMatchers(): InlineTypeEntry[];
|
|
319
|
+
listSlashCommands(): unknown[];
|
|
320
|
+
listAtCommands(): unknown[];
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export function createInlineRegistry(): InlineRegistry;
|
|
324
|
+
|
|
325
|
+
/** Opaque block-type definition value, passed to registerBlocks — see the individual `xBlockType` exports below. */
|
|
326
|
+
export type BlockTypeDefinition = BlockTypeEntry;
|
|
327
|
+
/** Opaque inline-type definition value, passed to registerInlineTypes — see the individual `xInlineType` exports below. */
|
|
328
|
+
export type InlineTypeDefinition = InlineTypeEntry;
|
|
329
|
+
|
|
330
|
+
export function registerBuiltInBlocks(registry: BlockRegistry): void;
|
|
331
|
+
export function registerBlocks(registry: BlockRegistry, types: Record<string, BlockTypeDefinition>): void;
|
|
332
|
+
export const TABLE_BLOCKS: Record<string, BlockTypeDefinition>;
|
|
333
|
+
export const LAYOUT_BLOCKS: Record<string, BlockTypeDefinition>;
|
|
334
|
+
|
|
335
|
+
export const paragraphBlockType: BlockTypeDefinition;
|
|
336
|
+
export const headingBlockType: BlockTypeDefinition;
|
|
337
|
+
export const listItemBlockType: BlockTypeDefinition;
|
|
338
|
+
export const tableBlockType: BlockTypeDefinition;
|
|
339
|
+
export const tableRowBlockType: BlockTypeDefinition;
|
|
340
|
+
export const tableCellBlockType: BlockTypeDefinition;
|
|
341
|
+
export const layoutBlockType: BlockTypeDefinition;
|
|
342
|
+
export const layoutColumnBlockType: BlockTypeDefinition;
|
|
343
|
+
export const dividerBlockType: BlockTypeDefinition;
|
|
344
|
+
export const calloutBlockType: BlockTypeDefinition;
|
|
345
|
+
export const blockquoteBlockType: BlockTypeDefinition;
|
|
346
|
+
export const codeBlockType: BlockTypeDefinition;
|
|
347
|
+
export const toggleHeadingBlockType: BlockTypeDefinition;
|
|
348
|
+
export const buttonBlockType: BlockTypeDefinition;
|
|
349
|
+
export const embedBlockType: BlockTypeDefinition;
|
|
350
|
+
|
|
351
|
+
export function registerBuiltInInlineTypes(inlineRegistry: InlineRegistry): void;
|
|
352
|
+
export function registerInlineTypes(inlineRegistry: InlineRegistry, types: Record<string, InlineTypeDefinition>): void;
|
|
353
|
+
export const TABLE_SELECT_INLINE_TYPES: Record<string, InlineTypeDefinition>;
|
|
354
|
+
|
|
355
|
+
export const selectInlineType: InlineTypeDefinition;
|
|
356
|
+
export const dateInlineType: InlineTypeDefinition;
|
|
357
|
+
export const checkboxInlineType: InlineTypeDefinition;
|
|
358
|
+
export const tableSelectInlineType: InlineTypeDefinition;
|
|
359
|
+
export const emojiInlineType: InlineTypeDefinition;
|
|
360
|
+
|
|
361
|
+
// ---------------------------------------------------------------------------
|
|
362
|
+
// react/ — provider, core hooks
|
|
363
|
+
// ---------------------------------------------------------------------------
|
|
364
|
+
|
|
365
|
+
export interface EditorProviderProps {
|
|
366
|
+
store: EditorStore | History;
|
|
367
|
+
registry: BlockRegistry;
|
|
368
|
+
inlineRegistry?: InlineRegistry | null;
|
|
369
|
+
history?: History | null;
|
|
370
|
+
className?: string;
|
|
371
|
+
style?: CSSProperties;
|
|
372
|
+
theme?: 'default' | 'none';
|
|
373
|
+
getBlockClassName?: (block: Block) => string | undefined;
|
|
374
|
+
children?: ReactNode;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export function EditorProvider(props: EditorProviderProps): ReactElement;
|
|
378
|
+
export function useEditorStore(): EditorStore | History;
|
|
379
|
+
export function useBlockRegistry(): BlockRegistry;
|
|
380
|
+
export function useInlineRegistry(): InlineRegistry | null;
|
|
381
|
+
export function useWholeDocumentSelection(): [boolean, (value: boolean) => void];
|
|
382
|
+
export function useBlockRangeSelection(): [string[], (ids: string[]) => void];
|
|
383
|
+
export function useSelectedBlock(): [string | null, (id: string | null) => void];
|
|
384
|
+
export function usePreviewMode(): [boolean, (value: boolean) => void];
|
|
385
|
+
export function useFieldTypeEditor(): {
|
|
386
|
+
editingFieldTypeId: string | null;
|
|
387
|
+
openFieldTypeEditor: (id: string | null) => void;
|
|
388
|
+
closeFieldTypeEditor: () => void;
|
|
389
|
+
};
|
|
390
|
+
export function useBlockClassName(baseClassName: string | undefined, block: Block): string | undefined;
|
|
391
|
+
|
|
392
|
+
export function injectDefaultStyles(): void;
|
|
393
|
+
|
|
394
|
+
export function useBlock(id: string): Block | undefined;
|
|
395
|
+
export function useRun(id: string): Run | undefined;
|
|
396
|
+
export function useFieldTypes(): FieldType[];
|
|
397
|
+
|
|
398
|
+
export interface UseHistoryResult {
|
|
399
|
+
canUndo: boolean;
|
|
400
|
+
canRedo: boolean;
|
|
401
|
+
undo: () => boolean;
|
|
402
|
+
redo: () => boolean;
|
|
403
|
+
getHistoryLog: () => HistoryLogEntry[];
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export function useHistory(): UseHistoryResult | null;
|
|
407
|
+
|
|
408
|
+
export function usePersistedDocument(options: {
|
|
409
|
+
store: EditorStore | History;
|
|
410
|
+
docId: string;
|
|
411
|
+
debounceMs?: number;
|
|
412
|
+
onError?: (error: unknown) => void;
|
|
413
|
+
}): { isLoaded: boolean };
|
|
414
|
+
|
|
415
|
+
export function usePresence(session: CollabSession | null | undefined): Map<string, Record<string, unknown>>;
|
|
416
|
+
|
|
417
|
+
export function useServiceWorkerUpdate(): { updateAvailable: boolean; applyUpdate: () => void };
|
|
418
|
+
|
|
419
|
+
export function useVoiceTyping(options?: Record<string, unknown>): Record<string, unknown>;
|
|
420
|
+
export const VoicePermissionModal: ComponentType<Record<string, unknown>>;
|
|
421
|
+
export const VoiceListeningIndicator: ComponentType<Record<string, unknown>>;
|
|
422
|
+
export function useCaretRect(...args: unknown[]): unknown;
|
|
423
|
+
export function listVoiceCommands(): Array<{ phrase: string; description: string }>;
|
|
424
|
+
|
|
425
|
+
export function useBlockChildren(parentId: string): string[];
|
|
426
|
+
|
|
427
|
+
export interface ClipboardHandlers {
|
|
428
|
+
onCopy: (event: ClipboardEvent<HTMLElement>) => void;
|
|
429
|
+
onCut: (event: ClipboardEvent<HTMLElement>) => void;
|
|
430
|
+
onPaste: (event: ClipboardEvent<HTMLElement>) => void;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
export function useClipboardHandlers(): ClipboardHandlers;
|
|
434
|
+
export function useEditorKeyboardShortcuts(containerRef: RefObject<HTMLElement | null>): void;
|
|
435
|
+
|
|
436
|
+
export const BlockRenderer: ComponentType<{ id: string }>;
|
|
437
|
+
export const BlockErrorBoundary: ComponentType<{ children?: ReactNode }>;
|
|
438
|
+
export const BlockChildren: ComponentType<{ parentId: string; isTopLevel?: boolean }>;
|
|
439
|
+
export const BlockGutterRow: ComponentType<Record<string, unknown>>;
|
|
440
|
+
export const BlockRangeActionMenu: ComponentType<Record<string, unknown>>;
|
|
441
|
+
export function useBlockRangeDrag(containerRef: RefObject<HTMLElement | null>): void;
|
|
442
|
+
export function useCoarsePointer(): boolean;
|
|
443
|
+
export function useVirtualKeyboardInset(): number;
|
|
444
|
+
export const MobileActionBar: ComponentType<{ containerRef: RefObject<HTMLElement | null> }>;
|
|
445
|
+
export const MobileBlockPickerSheet: ComponentType<Record<string, unknown>>;
|
|
446
|
+
export const MobileBlockOptionsSheet: ComponentType<Record<string, unknown>>;
|
|
447
|
+
export const EditableBlockContent: ComponentType<Record<string, unknown>>;
|
|
448
|
+
export const Modal: ComponentType<{ isOpen?: boolean; onClose?: () => void; children?: ReactNode; [key: string]: unknown }>;
|
|
449
|
+
export const Select: ComponentType<Record<string, unknown>>;
|
|
450
|
+
export const EditorTrailingSpace: ComponentType<Record<string, unknown>>;
|
|
451
|
+
|
|
452
|
+
// ---------------------------------------------------------------------------
|
|
453
|
+
// clipboard/
|
|
454
|
+
// ---------------------------------------------------------------------------
|
|
455
|
+
|
|
456
|
+
export const APP_MIME: string;
|
|
457
|
+
export function serializeBlockRange(...args: unknown[]): unknown;
|
|
458
|
+
export function remapSubtreeIds(...args: unknown[]): unknown;
|
|
459
|
+
export function deserializeClipboard(...args: unknown[]): unknown;
|
|
460
|
+
export function walkDomToBlocks(...args: unknown[]): unknown;
|
|
461
|
+
export function textToParagraphs(...args: unknown[]): unknown;
|
|
462
|
+
export function exportDocumentJSON(store: EditorStore | History): unknown;
|
|
463
|
+
export function exportDocumentHTML(store: EditorStore | History, registry: BlockRegistry): string;
|
|
464
|
+
export function exportDocumentText(store: EditorStore | History, registry: BlockRegistry): string;
|
|
465
|
+
export function exportDocumentSimpleJSON(store: EditorStore | History, registry: BlockRegistry, inlineRegistry: InlineRegistry): unknown;
|
|
466
|
+
export function importDocumentSimpleJSON(json: unknown, registry: BlockRegistry, inlineRegistry: InlineRegistry): DocumentJSON;
|
|
467
|
+
export const DocumentExportButton: ComponentType<Record<string, unknown>>;
|
|
468
|
+
|
|
469
|
+
// ---------------------------------------------------------------------------
|
|
470
|
+
// commands/
|
|
471
|
+
// ---------------------------------------------------------------------------
|
|
472
|
+
|
|
473
|
+
export interface CommandMenuTriggerState {
|
|
474
|
+
isOpen: boolean;
|
|
475
|
+
rect: { top: number; left: number; bottom: number; right: number } | null;
|
|
476
|
+
commands: unknown[];
|
|
477
|
+
runId: string | null;
|
|
478
|
+
selectCommand: (command: unknown) => void;
|
|
479
|
+
close: () => void;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
export interface SlashMenuProps {
|
|
483
|
+
isOpen: boolean;
|
|
484
|
+
rect: CommandMenuTriggerState['rect'];
|
|
485
|
+
commands: unknown[];
|
|
486
|
+
runId: string | null;
|
|
487
|
+
onSelect: (command: unknown) => void;
|
|
488
|
+
onClose: () => void;
|
|
489
|
+
menuId?: string;
|
|
490
|
+
ariaLabel?: string;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export const SlashMenu: ComponentType<SlashMenuProps>;
|
|
494
|
+
export function useSlashMenuTrigger(containerRef: RefObject<HTMLElement | null>): CommandMenuTriggerState;
|
|
495
|
+
export function useEmojiMenuTrigger(containerRef: RefObject<HTMLElement | null>): CommandMenuTriggerState;
|
|
496
|
+
export function useAtMenuTrigger(containerRef: RefObject<HTMLElement | null>): CommandMenuTriggerState;
|
|
497
|
+
|
|
498
|
+
export interface FloatingToolbarProps {
|
|
499
|
+
isOpen: boolean;
|
|
500
|
+
rect: CommandMenuTriggerState['rect'];
|
|
501
|
+
kind: string | null;
|
|
502
|
+
selection: unknown;
|
|
503
|
+
crossSelection: unknown;
|
|
504
|
+
marks: Record<string, unknown>;
|
|
505
|
+
store: EditorStore | History;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
export const FloatingToolbar: ComponentType<FloatingToolbarProps>;
|
|
509
|
+
export function useFloatingToolbarTrigger(containerRef: RefObject<HTMLElement | null>): {
|
|
510
|
+
isOpen: boolean;
|
|
511
|
+
rect: CommandMenuTriggerState['rect'];
|
|
512
|
+
kind: string | null;
|
|
513
|
+
selection: unknown;
|
|
514
|
+
crossSelection: unknown;
|
|
515
|
+
marks: Record<string, unknown>;
|
|
516
|
+
};
|
|
517
|
+
export function useTextFormattingActions(...args: unknown[]): unknown;
|
|
518
|
+
|
|
519
|
+
// ---------------------------------------------------------------------------
|
|
520
|
+
// blocks/table/
|
|
521
|
+
// ---------------------------------------------------------------------------
|
|
522
|
+
|
|
523
|
+
export function insertRowAfter(...args: unknown[]): unknown;
|
|
524
|
+
export function deleteRow(...args: unknown[]): unknown;
|
|
525
|
+
export function insertColumnAfter(...args: unknown[]): unknown;
|
|
526
|
+
export function deleteColumn(...args: unknown[]): unknown;
|
|
527
|
+
export function renameColumn(...args: unknown[]): unknown;
|
|
528
|
+
export function setColumnType(...args: unknown[]): unknown;
|
|
529
|
+
export function setColumnOptions(...args: unknown[]): unknown;
|
|
530
|
+
export function setColumnWidth(...args: unknown[]): unknown;
|
|
531
|
+
export function resolveColumns(...args: unknown[]): unknown;
|
|
532
|
+
export function createDefaultColumns(...args: unknown[]): unknown;
|
|
533
|
+
export function createCellForColumn(...args: unknown[]): unknown;
|
|
534
|
+
export function convertRunToType(...args: unknown[]): unknown;
|
|
535
|
+
export function blankRunForType(...args: unknown[]): unknown;
|
|
536
|
+
export const COLUMN_TYPES: Record<string, string>;
|
|
537
|
+
export const DEFAULT_COLUMN_TYPE: string;
|
|
538
|
+
export const DEFAULT_COLUMN_WIDTH: number;
|
|
539
|
+
export const MIN_COLUMN_WIDTH: number;
|
|
540
|
+
export const TableHeaderRow: ComponentType<Record<string, unknown>>;
|
|
541
|
+
|
|
542
|
+
// ---------------------------------------------------------------------------
|
|
543
|
+
// inline/, react/ selection & shared block actions
|
|
544
|
+
// ---------------------------------------------------------------------------
|
|
545
|
+
|
|
546
|
+
export function toggleMarkOnRunRange(...args: unknown[]): unknown;
|
|
547
|
+
export function toggleMarkOverSelection(...args: unknown[]): unknown;
|
|
548
|
+
export function toggleMarkOverBlockRange(...args: unknown[]): unknown;
|
|
549
|
+
export function setMarksOverSelection(...args: unknown[]): unknown;
|
|
550
|
+
export function setMarksOverBlockRange(...args: unknown[]): unknown;
|
|
551
|
+
export function getMarksSummaryOverSelection(...args: unknown[]): Record<string, unknown>;
|
|
552
|
+
export function getMarksSummaryOverBlockRange(...args: unknown[]): Record<string, unknown>;
|
|
553
|
+
export function deleteRunRangeInBlock(...args: unknown[]): unknown;
|
|
554
|
+
export function deleteOverBlockRange(...args: unknown[]): unknown;
|
|
555
|
+
export function deleteEntireDocument(...args: unknown[]): unknown;
|
|
556
|
+
export function resolveRunSelection(...args: unknown[]): unknown;
|
|
557
|
+
export function resolveMultiRunSelection(...args: unknown[]): unknown;
|
|
558
|
+
export function resolveCrossBlockSelection(...args: unknown[]): unknown;
|
|
559
|
+
export function resolveCollapsedCaret(...args: unknown[]): unknown;
|
|
560
|
+
export function isEntireBlockSelected(...args: unknown[]): boolean;
|
|
561
|
+
export function focusRunEnd(runId: string): void;
|
|
562
|
+
export function focusRunStart(runId: string): void;
|
|
563
|
+
export function focusRunAtOffset(runId: string, offset: number): void;
|
|
564
|
+
export function ensureRootNonEmpty(store: EditorStore | History): void;
|
|
565
|
+
export function duplicateBlock(...args: unknown[]): unknown;
|
|
566
|
+
export function moveBlockUp(...args: unknown[]): unknown;
|
|
567
|
+
export function moveBlockDown(...args: unknown[]): unknown;
|
|
568
|
+
export function deleteBlockAndFocusSibling(...args: unknown[]): unknown;
|
|
569
|
+
export function deleteBlockRange(...args: unknown[]): unknown;
|
|
570
|
+
export function moveBlockRangeUp(...args: unknown[]): unknown;
|
|
571
|
+
export function moveBlockRangeDown(...args: unknown[]): unknown;
|
|
572
|
+
export function isEntireBlockRangeHidden(...args: unknown[]): boolean;
|
|
573
|
+
export function setBlockRangeHidden(...args: unknown[]): unknown;
|
|
574
|
+
export function reorderBlockRangeFromStore(...args: unknown[]): unknown;
|
|
575
|
+
export function copyBlockRangeToClipboard(...args: unknown[]): unknown;
|
|
576
|
+
|
|
577
|
+
// ---------------------------------------------------------------------------
|
|
578
|
+
// inlineTypes/customSelect/ — user-authored custom field types
|
|
579
|
+
// ---------------------------------------------------------------------------
|
|
580
|
+
|
|
581
|
+
export function createSelectFieldType(options: Record<string, unknown>): InlineTypeDefinition;
|
|
582
|
+
export function registerStoredFieldTypes(inlineRegistry: InlineRegistry, fieldTypes: FieldType[]): void;
|
|
583
|
+
export function useRegisterFieldTypes(inlineRegistry: InlineRegistry, fieldTypes: FieldType[]): void;
|
|
584
|
+
export const FieldTypeEditorModal: ComponentType<Record<string, unknown>>;
|
|
585
|
+
|
|
586
|
+
// ---------------------------------------------------------------------------
|
|
587
|
+
// react/useEditor.js, react/NoteloomEditor.jsx — the simplified entry point
|
|
588
|
+
// ---------------------------------------------------------------------------
|
|
589
|
+
|
|
590
|
+
export interface UseEditorOptions {
|
|
591
|
+
/** Starting document; defaults to one empty paragraph. */
|
|
592
|
+
doc?: DocumentJSON;
|
|
593
|
+
/** true (default): store is undo/redo-aware (a History instance). false: a plain EditorStore. */
|
|
594
|
+
history?: boolean;
|
|
595
|
+
/** Replaces registerBuiltInBlocks for an opt-in subset of block types. */
|
|
596
|
+
registerBlocks?: (registry: BlockRegistry) => void;
|
|
597
|
+
/** Replaces registerBuiltInInlineTypes for an opt-in subset of inline types. */
|
|
598
|
+
registerInlineTypes?: (inlineRegistry: InlineRegistry) => void;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
export interface UseEditorResult {
|
|
602
|
+
store: History | EditorStore;
|
|
603
|
+
registry: BlockRegistry;
|
|
604
|
+
inlineRegistry: InlineRegistry;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/** The one-call path to a working editor — see the README's Quick start. */
|
|
608
|
+
export function useEditor(options?: UseEditorOptions): UseEditorResult;
|
|
609
|
+
|
|
610
|
+
export interface NoteloomEditorProps {
|
|
611
|
+
editor: UseEditorResult;
|
|
612
|
+
className?: string;
|
|
613
|
+
style?: CSSProperties;
|
|
614
|
+
theme?: 'default' | 'none';
|
|
615
|
+
getBlockClassName?: (block: Block) => string | undefined;
|
|
616
|
+
children?: ReactNode;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/** Renders the object useEditor() returned, with every built-in interaction wired up. */
|
|
620
|
+
export function NoteloomEditor(props: NoteloomEditorProps): ReactElement;
|