noteloom 0.1.7 → 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 +827 -438
- package/dist/index.d.ts +849 -0
- package/dist/noteloom.cjs +418 -12
- package/dist/noteloom.cjs.map +1 -1
- package/dist/noteloom.es.js +8636 -6289
- package/dist/noteloom.es.js.map +1 -1
- package/dist/style.css +410 -4
- package/package.json +31 -6
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,849 @@
|
|
|
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 CommentMessage {
|
|
42
|
+
id: string;
|
|
43
|
+
authorId: string;
|
|
44
|
+
text: string;
|
|
45
|
+
createdAt: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface CommentThread {
|
|
49
|
+
id: string;
|
|
50
|
+
blockId: string;
|
|
51
|
+
/** Creation-time hint only, not re-validated after later formatting edits -- see the README's documented limitation. */
|
|
52
|
+
anchorRunIds: string[];
|
|
53
|
+
resolved: boolean;
|
|
54
|
+
messages: CommentMessage[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface DocumentJSON {
|
|
58
|
+
rootId: string;
|
|
59
|
+
blocks: Block[];
|
|
60
|
+
runs: Run[];
|
|
61
|
+
fieldTypes?: FieldType[];
|
|
62
|
+
comments?: CommentThread[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type Operation = { type: string; [key: string]: unknown };
|
|
66
|
+
export type OperationInverse = Operation;
|
|
67
|
+
|
|
68
|
+
/** Opaque envelope shape carried between EditorStore.applyRemoteOperation and CollabSession/syncProtocol — kind-discriminated, see EditorStore.js. */
|
|
69
|
+
export type RemoteOperationEnvelope = { kind: string; [key: string]: unknown };
|
|
70
|
+
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
// store/operations.js
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
export const OP: {
|
|
76
|
+
INSERT_BLOCK: 'insertBlock';
|
|
77
|
+
REMOVE_BLOCK: 'removeBlock';
|
|
78
|
+
MOVE_BLOCK: 'moveBlock';
|
|
79
|
+
CHANGE_BLOCK_TYPE: 'changeBlockType';
|
|
80
|
+
UPDATE_BLOCK_PROPS: 'updateBlockProps';
|
|
81
|
+
UPDATE_RUN: 'updateRun';
|
|
82
|
+
SET_BLOCK_CONTENT_IDS: 'setBlockContentIds';
|
|
83
|
+
REPLACE_RUN_SPAN: 'replaceRunSpan';
|
|
84
|
+
SET_BLOCK_RUNS: 'setBlockRuns';
|
|
85
|
+
ADD_FIELD_TYPE: 'addFieldType';
|
|
86
|
+
UPDATE_FIELD_TYPE: 'updateFieldType';
|
|
87
|
+
REMOVE_FIELD_TYPE: 'removeFieldType';
|
|
88
|
+
ADD_COMMENT_THREAD: 'addCommentThread';
|
|
89
|
+
REMOVE_COMMENT_THREAD: 'removeCommentThread';
|
|
90
|
+
ADD_COMMENT_REPLY: 'addCommentReply';
|
|
91
|
+
REMOVE_COMMENT_REPLY: 'removeCommentReply';
|
|
92
|
+
RESOLVE_COMMENT: 'resolveComment';
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export namespace operations {
|
|
96
|
+
export function insertBlock(block: Block, parentId: string, index: number, subtree?: { blocks: Block[]; runs: Run[] }): Operation;
|
|
97
|
+
export function removeBlock(id: string): Operation;
|
|
98
|
+
export function moveBlock(id: string, toParentId: string, toIndex: number): Operation;
|
|
99
|
+
export function updateBlockProps(id: string, patch: Record<string, unknown>): Operation;
|
|
100
|
+
export function changeBlockType(id: string, blockType: string, props: Record<string, unknown>): Operation;
|
|
101
|
+
export function updateRun(id: string, patch: Record<string, unknown>): Operation;
|
|
102
|
+
export function setBlockContentIds(blockId: string, contentIds: string[]): Operation;
|
|
103
|
+
export function replaceRunSpan(blockId: string, oldRunIds: string[], newRuns: Run[]): Operation;
|
|
104
|
+
export function setBlockRuns(blockId: string, runs: Run[]): Operation;
|
|
105
|
+
export function addFieldType(fieldType: FieldType): Operation;
|
|
106
|
+
export function updateFieldType(id: string, patch: Partial<FieldType>): Operation;
|
|
107
|
+
export function removeFieldType(id: string): Operation;
|
|
108
|
+
export function addCommentThread(thread: CommentThread): Operation;
|
|
109
|
+
export function removeCommentThread(commentId: string): Operation;
|
|
110
|
+
export function addCommentReply(commentId: string, message: CommentMessage): Operation;
|
|
111
|
+
export function removeCommentReply(commentId: string, messageId: string): Operation;
|
|
112
|
+
export function resolveComment(commentId: string, resolved: boolean): Operation;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
// store/EditorStore.js, store/history.js
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
export class EditorStore {
|
|
120
|
+
constructor(doc?: DocumentJSON);
|
|
121
|
+
blocks: Map<string, Block>;
|
|
122
|
+
runs: Map<string, Run>;
|
|
123
|
+
rootId: string | null;
|
|
124
|
+
fieldTypes: Map<string, FieldType>;
|
|
125
|
+
comments: Map<string, CommentThread>;
|
|
126
|
+
|
|
127
|
+
getBlock(id: string): Block | undefined;
|
|
128
|
+
getRun(id: string): Run | undefined;
|
|
129
|
+
getFieldTypes(): FieldType[];
|
|
130
|
+
getFieldType(id: string): FieldType | undefined;
|
|
131
|
+
getComments(): CommentThread[];
|
|
132
|
+
getComment(id: string): CommentThread | undefined;
|
|
133
|
+
/** Every run id in the whole document, regardless of reachability from the root -- see removeCommentMarkEverywhere. */
|
|
134
|
+
getAllRunIds(): string[];
|
|
135
|
+
getRootId(): string | null;
|
|
136
|
+
subscribe(id: string, listener: () => void): () => void;
|
|
137
|
+
subscribeAll(listener: () => void): () => void;
|
|
138
|
+
applyOperation(op: Operation): OperationInverse;
|
|
139
|
+
applyOperations(ops: Operation[]): OperationInverse[];
|
|
140
|
+
getLastEnvelope(): RemoteOperationEnvelope | null;
|
|
141
|
+
applyRemoteOperation(envelope: RemoteOperationEnvelope): void;
|
|
142
|
+
getTombstoneCount(): number;
|
|
143
|
+
pruneTombstones(options?: { maxAgeMs?: number; now?: number }): number;
|
|
144
|
+
toJSON(): DocumentJSON;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface HistoryOptions {
|
|
148
|
+
idleMs?: number;
|
|
149
|
+
trackChanges?: boolean;
|
|
150
|
+
maxChangeLogSize?: number;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface HistoryLogEntry {
|
|
154
|
+
opType: string;
|
|
155
|
+
id: string | undefined;
|
|
156
|
+
actorId: string | null;
|
|
157
|
+
timestamp: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface ChangeLogEntry extends HistoryLogEntry {
|
|
161
|
+
before?: unknown;
|
|
162
|
+
after?: unknown;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface OperationMeta {
|
|
166
|
+
actorId?: string | null;
|
|
167
|
+
timestamp?: number;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Wraps an EditorStore with undo/redo — exposes the same read surface, so anything typed against `EditorStore` also accepts a `History` instance. */
|
|
171
|
+
export class History {
|
|
172
|
+
constructor(store: EditorStore, options?: HistoryOptions);
|
|
173
|
+
store: EditorStore;
|
|
174
|
+
|
|
175
|
+
getBlock(id: string): Block | undefined;
|
|
176
|
+
getRun(id: string): Run | undefined;
|
|
177
|
+
getRootId(): string | null;
|
|
178
|
+
getFieldTypes(): FieldType[];
|
|
179
|
+
getFieldType(id: string): FieldType | undefined;
|
|
180
|
+
getComments(): CommentThread[];
|
|
181
|
+
getComment(id: string): CommentThread | undefined;
|
|
182
|
+
getAllRunIds(): string[];
|
|
183
|
+
subscribe(id: string, listener: () => void): () => void;
|
|
184
|
+
subscribeAll(listener: () => void): () => void;
|
|
185
|
+
getTombstoneCount(): number;
|
|
186
|
+
pruneTombstones(options?: { maxAgeMs?: number; now?: number }): number;
|
|
187
|
+
toJSON(): DocumentJSON;
|
|
188
|
+
|
|
189
|
+
applyOperation(op: Operation, meta?: OperationMeta): OperationInverse;
|
|
190
|
+
applyOperations(ops: Operation[], meta?: OperationMeta): OperationInverse[];
|
|
191
|
+
performBatch(ops: Operation[], meta?: OperationMeta): void;
|
|
192
|
+
perform(op: Operation, meta?: OperationMeta): OperationInverse;
|
|
193
|
+
flush(): void;
|
|
194
|
+
undo(): boolean;
|
|
195
|
+
redo(): boolean;
|
|
196
|
+
canUndo(): boolean;
|
|
197
|
+
canRedo(): boolean;
|
|
198
|
+
getPendingSelection(): { runId: string; offset: number } | null;
|
|
199
|
+
getPendingAffectedBlockIds(): string[];
|
|
200
|
+
getUndoRedoSnapshot(): { canUndo: boolean; canRedo: boolean };
|
|
201
|
+
getHistoryLog(): HistoryLogEntry[];
|
|
202
|
+
getChangeLog(): ChangeLogEntry[];
|
|
203
|
+
subscribeToHistory(listener: () => void): () => void;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
// crdt/
|
|
208
|
+
// ---------------------------------------------------------------------------
|
|
209
|
+
|
|
210
|
+
export interface HlcTimestamp {
|
|
211
|
+
physical: number;
|
|
212
|
+
logical: number;
|
|
213
|
+
peerId: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export class HLC {
|
|
217
|
+
constructor(peerId: string);
|
|
218
|
+
tick(): HlcTimestamp;
|
|
219
|
+
receive(remote: HlcTimestamp): HlcTimestamp;
|
|
220
|
+
static compare(a: HlcTimestamp, b: HlcTimestamp): number;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function genPeerId(): string;
|
|
224
|
+
|
|
225
|
+
export interface ListCrdtSlot {
|
|
226
|
+
id: string;
|
|
227
|
+
originId: string | null;
|
|
228
|
+
clock: HlcTimestamp;
|
|
229
|
+
deletedClock?: HlcTimestamp | null;
|
|
230
|
+
[key: string]: unknown;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export class ListCrdtState {
|
|
234
|
+
static fromArray(ids: string[], options?: { peerId?: string }): ListCrdtState;
|
|
235
|
+
has(id: string): boolean;
|
|
236
|
+
getSlot(id: string): ListCrdtSlot | undefined;
|
|
237
|
+
isDeleted(id: string): boolean;
|
|
238
|
+
insert(id: string, afterId: string | null, clock: HlcTimestamp, peerId: string): ListCrdtSlot;
|
|
239
|
+
delete(id: string, clock: HlcTimestamp): void;
|
|
240
|
+
restore(id: string): void;
|
|
241
|
+
move(id: string, afterId: string | null, clock: HlcTimestamp, peerId: string): void;
|
|
242
|
+
merge(remoteSlots: ListCrdtSlot[]): void;
|
|
243
|
+
toSlotArray(): ListCrdtSlot[];
|
|
244
|
+
toArray(): string[];
|
|
245
|
+
tombstoneCount(): number;
|
|
246
|
+
pruneTombstones(beforeClock: HlcTimestamp): number;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export class FieldClockRegistry {
|
|
250
|
+
shouldApply(key: string, clock: HlcTimestamp): boolean;
|
|
251
|
+
record(key: string, clock: HlcTimestamp): void;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function createPeriodicTombstoneGC(options: {
|
|
255
|
+
store: EditorStore | History;
|
|
256
|
+
intervalMs?: number;
|
|
257
|
+
maxAgeMs?: number;
|
|
258
|
+
onPrune?: (prunedCount: number) => void;
|
|
259
|
+
onError?: (error: unknown) => void;
|
|
260
|
+
}): { stop: () => void };
|
|
261
|
+
|
|
262
|
+
// ---------------------------------------------------------------------------
|
|
263
|
+
// sync/
|
|
264
|
+
// ---------------------------------------------------------------------------
|
|
265
|
+
|
|
266
|
+
export interface SignalingChannel {
|
|
267
|
+
send(message: unknown): void;
|
|
268
|
+
onMessage(handler: (message: unknown) => void): () => void;
|
|
269
|
+
close(): void;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export const MESSAGE_TYPE: {
|
|
273
|
+
HELLO: string;
|
|
274
|
+
OP: string;
|
|
275
|
+
SYNC_REQUEST: string;
|
|
276
|
+
SYNC_RESPONSE: string;
|
|
277
|
+
PRESENCE: string;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export function encodeMessage(message: unknown): string;
|
|
281
|
+
export function decodeMessage(raw: string): unknown;
|
|
282
|
+
|
|
283
|
+
export class PeerConnection {
|
|
284
|
+
constructor(options: { peerConnection: RTCPeerConnection; dataChannel?: RTCDataChannel; onMessage?: (message: unknown) => void });
|
|
285
|
+
send(message: unknown): void;
|
|
286
|
+
close(): void;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export class CollabSession {
|
|
290
|
+
constructor(options: { history: History | EditorStore; signaling: SignalingChannel; presenceThrottleMs?: number });
|
|
291
|
+
connect(remotePeerId: string, options: { initiator: boolean }): void;
|
|
292
|
+
disconnect(remotePeerId: string): void;
|
|
293
|
+
destroy(): void;
|
|
294
|
+
setLocalPresence(data: Record<string, unknown>): void;
|
|
295
|
+
getPresence(): Map<string, Record<string, unknown>>;
|
|
296
|
+
onPresenceChange(callback: (presence: Map<string, Record<string, unknown>>) => void): () => void;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export function createWebSocketSignaling(options: {
|
|
300
|
+
url: string;
|
|
301
|
+
roomId: string;
|
|
302
|
+
peerId: string;
|
|
303
|
+
WebSocketImpl?: typeof WebSocket;
|
|
304
|
+
}): SignalingChannel;
|
|
305
|
+
|
|
306
|
+
// ---------------------------------------------------------------------------
|
|
307
|
+
// persistence/
|
|
308
|
+
// ---------------------------------------------------------------------------
|
|
309
|
+
|
|
310
|
+
export function savePersistedDocument(docId: string, doc: DocumentJSON): Promise<void>;
|
|
311
|
+
export function loadPersistedDocument(docId: string): Promise<DocumentJSON | undefined>;
|
|
312
|
+
export function deletePersistedDocument(docId: string): Promise<void>;
|
|
313
|
+
export function listPersistedDocumentIds(): Promise<string[]>;
|
|
314
|
+
|
|
315
|
+
export function createAutoPersistence(options: {
|
|
316
|
+
store: History | EditorStore;
|
|
317
|
+
docId: string;
|
|
318
|
+
debounceMs?: number;
|
|
319
|
+
onError?: (error: unknown) => void;
|
|
320
|
+
}): { stop: () => void; flush: () => void };
|
|
321
|
+
|
|
322
|
+
// ---------------------------------------------------------------------------
|
|
323
|
+
// templates/ (+ the template half of persistence/)
|
|
324
|
+
// ---------------------------------------------------------------------------
|
|
325
|
+
|
|
326
|
+
/** One captured block-template root — see captureBlockTemplate. */
|
|
327
|
+
export interface BlockTemplate {
|
|
328
|
+
roots: CapturedSubtree[];
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export interface StoredTemplate {
|
|
332
|
+
id: string;
|
|
333
|
+
scope: 'document' | 'block';
|
|
334
|
+
name: string;
|
|
335
|
+
description?: string;
|
|
336
|
+
/** A full DocumentJSON for scope 'document', or a BlockTemplate ({ roots }) for scope 'block'. */
|
|
337
|
+
doc: DocumentJSON | BlockTemplate;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export function saveTemplate(template: StoredTemplate): Promise<void>;
|
|
341
|
+
export function loadTemplate(id: string): Promise<StoredTemplate | null>;
|
|
342
|
+
export function deleteTemplate(id: string): Promise<void>;
|
|
343
|
+
export function listTemplates(): Promise<StoredTemplate[]>;
|
|
344
|
+
|
|
345
|
+
export function captureBlockTemplate(store: EditorStore | History, blockIds: string[]): BlockTemplate;
|
|
346
|
+
export function insertBlockTemplate(
|
|
347
|
+
store: EditorStore | History,
|
|
348
|
+
template: BlockTemplate,
|
|
349
|
+
position: { parentId: string; index: number },
|
|
350
|
+
): void;
|
|
351
|
+
/** Wholesale-replaces an already-mounted editor's content with a document template. To start a NEW editor from one instead, just pass it as useEditor({ doc }). */
|
|
352
|
+
export function applyDocumentTemplate(store: EditorStore | History, doc: DocumentJSON): void;
|
|
353
|
+
|
|
354
|
+
export interface BlockTemplateDefinition {
|
|
355
|
+
id: string;
|
|
356
|
+
label: string;
|
|
357
|
+
icon?: ComponentType<{ size?: number }>;
|
|
358
|
+
keywords?: string[];
|
|
359
|
+
roots: CapturedSubtree[];
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** Registers block templates as slash commands, discoverable/insertable via "/" alongside every built-in block — no SlashMenu/BlockRegistry changes needed. */
|
|
363
|
+
export function registerBlockTemplates(registry: BlockRegistry, templates: BlockTemplateDefinition[]): void;
|
|
364
|
+
|
|
365
|
+
export function useTemplates(options?: { scope?: 'document' | 'block' }): {
|
|
366
|
+
templates: StoredTemplate[];
|
|
367
|
+
isLoaded: boolean;
|
|
368
|
+
refresh: () => Promise<void>;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
export interface TemplatePickerProps {
|
|
372
|
+
templates: StoredTemplate[];
|
|
373
|
+
onSelect: (template: StoredTemplate) => void;
|
|
374
|
+
emptyLabel?: string;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export const TemplatePicker: ComponentType<TemplatePickerProps>;
|
|
378
|
+
|
|
379
|
+
// ---------------------------------------------------------------------------
|
|
380
|
+
// versions/ (+ the version half of persistence/)
|
|
381
|
+
// ---------------------------------------------------------------------------
|
|
382
|
+
|
|
383
|
+
export interface DocumentVersion {
|
|
384
|
+
id: string;
|
|
385
|
+
docId: string;
|
|
386
|
+
timestamp: number;
|
|
387
|
+
label?: string;
|
|
388
|
+
doc: DocumentJSON;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export function saveDocumentVersion(version: DocumentVersion): Promise<void>;
|
|
392
|
+
export function loadDocumentVersion(id: string): Promise<DocumentVersion | null>;
|
|
393
|
+
export function deleteDocumentVersion(id: string): Promise<void>;
|
|
394
|
+
/** All versions saved for docId, newest first. */
|
|
395
|
+
export function listDocumentVersions(docId: string): Promise<DocumentVersion[]>;
|
|
396
|
+
|
|
397
|
+
/** Periodically snapshots a live document into the versions store; prunes oldest beyond maxVersions for this docId. Restore with applyDocumentTemplate(store, version.doc). */
|
|
398
|
+
export function createPeriodicVersionSnapshotter(options: {
|
|
399
|
+
store: History | EditorStore;
|
|
400
|
+
docId: string;
|
|
401
|
+
intervalMs?: number;
|
|
402
|
+
label?: string;
|
|
403
|
+
maxVersions?: number;
|
|
404
|
+
onSnapshot?: (version: DocumentVersion) => void;
|
|
405
|
+
onError?: (error: unknown) => void;
|
|
406
|
+
}): { stop: () => void };
|
|
407
|
+
|
|
408
|
+
export function useDocumentVersions(docId: string | null | undefined): {
|
|
409
|
+
versions: DocumentVersion[];
|
|
410
|
+
isLoaded: boolean;
|
|
411
|
+
refresh: () => Promise<void>;
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
// ---------------------------------------------------------------------------
|
|
415
|
+
// comments/
|
|
416
|
+
// ---------------------------------------------------------------------------
|
|
417
|
+
|
|
418
|
+
export interface CommentRange {
|
|
419
|
+
blockId: string;
|
|
420
|
+
startRunId: string;
|
|
421
|
+
startOffset: number;
|
|
422
|
+
endRunId: string;
|
|
423
|
+
endOffset: number;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Creates a comment thread anchored to `range`, highlighting it and creating the thread as one atomic undo step. Returns the new comment's id. */
|
|
427
|
+
export function addComment(store: EditorStore | History, range: CommentRange, message: { authorId: string; text: string }): string;
|
|
428
|
+
/** Appends a reply to an existing thread. Returns the new message's id. */
|
|
429
|
+
export function replyToComment(store: EditorStore | History, commentId: string, message: { authorId: string; text: string }): string;
|
|
430
|
+
/** Flips a thread's resolved flag (defaults to true). */
|
|
431
|
+
export function resolveComment(store: EditorStore | History, commentId: string, resolved?: boolean): void;
|
|
432
|
+
/** Removes a thread and strips its highlight from every run that still carries it, as one atomic undo step. */
|
|
433
|
+
export function deleteComment(store: EditorStore | History, commentId: string): void;
|
|
434
|
+
|
|
435
|
+
/** Computes (does not apply) the op that highlights `range` with `commentId` -- for advanced use; addComment already calls this. Returns null for a collapsed/unresolvable range. */
|
|
436
|
+
export function addCommentMarkOverRange(store: EditorStore | History, range: CommentRange, commentId: string): Operation | null;
|
|
437
|
+
/** Computes (does not apply) the ops that strip `commentId` from every run in the document that carries it. */
|
|
438
|
+
export function removeCommentMarkEverywhere(store: EditorStore | History, commentId: string): Operation[];
|
|
439
|
+
|
|
440
|
+
export function useComments(): CommentThread[];
|
|
441
|
+
|
|
442
|
+
export interface CommentComposerProps {
|
|
443
|
+
/** Renders the composer's own avatar preview -- does not decide who the message is attributed to (the caller still passes authorId to addComment/replyToComment). */
|
|
444
|
+
authorId?: string;
|
|
445
|
+
placeholder?: string;
|
|
446
|
+
autoFocus?: boolean;
|
|
447
|
+
onSubmit: (text: string) => void;
|
|
448
|
+
/** Renders a Cancel button when given. */
|
|
449
|
+
onCancel?: () => void;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** An avatar + textarea + send button for composing one comment message -- the shared piece CommentThreadCard's reply flow and FloatingToolbar's built-in Comment composer both use. */
|
|
453
|
+
export const CommentComposer: ComponentType<CommentComposerProps>;
|
|
454
|
+
|
|
455
|
+
export interface CommentAvatarProps {
|
|
456
|
+
authorId?: string;
|
|
457
|
+
size?: number;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/** A small colored circle with the author's initials, deterministically generated from authorId -- this package has no profile-picture/identity concept of its own. */
|
|
461
|
+
export const CommentAvatar: ComponentType<CommentAvatarProps>;
|
|
462
|
+
|
|
463
|
+
export interface CommentThreadCardProps {
|
|
464
|
+
store: EditorStore | History;
|
|
465
|
+
thread: CommentThread;
|
|
466
|
+
/** Hides the Reply action when not given -- composing a message needs an author. */
|
|
467
|
+
authorId?: string;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/** One comment thread -- messages, then Reply/Resolve/Delete. Shared by CommentPopover (click/hover on highlighted text, mounted automatically) and CommentsPanel. */
|
|
471
|
+
export const CommentThreadCard: ComponentType<CommentThreadCardProps>;
|
|
472
|
+
|
|
473
|
+
export interface CommentsPanelProps {
|
|
474
|
+
authorId?: string;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** The opt-in right-side comments panel (Notion/Google Docs-style) -- see NoteloomEditorProps.showCommentsPanel, or render it yourself anywhere under an EditorProvider for the granular API. */
|
|
478
|
+
export const CommentsPanel: ComponentType<CommentsPanelProps>;
|
|
479
|
+
|
|
480
|
+
// ---------------------------------------------------------------------------
|
|
481
|
+
// registry/, blocks/, inlineTypes/
|
|
482
|
+
// ---------------------------------------------------------------------------
|
|
483
|
+
|
|
484
|
+
export interface BlockTypeEntry {
|
|
485
|
+
component: ComponentType<{ id: string }>;
|
|
486
|
+
isLeaf: boolean;
|
|
487
|
+
defaultProps?: Record<string, unknown>;
|
|
488
|
+
[key: string]: unknown;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export class BlockRegistry {
|
|
492
|
+
register(type: string, entry: BlockTypeEntry): void;
|
|
493
|
+
get(type: string): BlockTypeEntry | undefined;
|
|
494
|
+
isLeaf(type: string): boolean;
|
|
495
|
+
listSlashCommands(): unknown[];
|
|
496
|
+
listHtmlMatchers(): BlockTypeEntry[];
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export function createBlockRegistry(): BlockRegistry;
|
|
500
|
+
|
|
501
|
+
export interface InlineTypeEntry {
|
|
502
|
+
component: ComponentType<{ id: string }>;
|
|
503
|
+
isAtomic: true;
|
|
504
|
+
[key: string]: unknown;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
export class InlineRegistry {
|
|
508
|
+
register(type: string, entry: InlineTypeEntry): void;
|
|
509
|
+
unregister(type: string): void;
|
|
510
|
+
get(type: string): InlineTypeEntry | undefined;
|
|
511
|
+
listHtmlMatchers(): InlineTypeEntry[];
|
|
512
|
+
listSlashCommands(): unknown[];
|
|
513
|
+
listAtCommands(): unknown[];
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export function createInlineRegistry(): InlineRegistry;
|
|
517
|
+
|
|
518
|
+
/** Opaque block-type definition value, passed to registerBlocks — see the individual `xBlockType` exports below. */
|
|
519
|
+
export type BlockTypeDefinition = BlockTypeEntry;
|
|
520
|
+
/** Opaque inline-type definition value, passed to registerInlineTypes — see the individual `xInlineType` exports below. */
|
|
521
|
+
export type InlineTypeDefinition = InlineTypeEntry;
|
|
522
|
+
|
|
523
|
+
export function registerBuiltInBlocks(registry: BlockRegistry): void;
|
|
524
|
+
export function registerBlocks(registry: BlockRegistry, types: Record<string, BlockTypeDefinition>): void;
|
|
525
|
+
export const TABLE_BLOCKS: Record<string, BlockTypeDefinition>;
|
|
526
|
+
export const LAYOUT_BLOCKS: Record<string, BlockTypeDefinition>;
|
|
527
|
+
|
|
528
|
+
export const paragraphBlockType: BlockTypeDefinition;
|
|
529
|
+
export const headingBlockType: BlockTypeDefinition;
|
|
530
|
+
export const listItemBlockType: BlockTypeDefinition;
|
|
531
|
+
export const tableBlockType: BlockTypeDefinition;
|
|
532
|
+
export const tableRowBlockType: BlockTypeDefinition;
|
|
533
|
+
export const tableCellBlockType: BlockTypeDefinition;
|
|
534
|
+
export const layoutBlockType: BlockTypeDefinition;
|
|
535
|
+
export const layoutColumnBlockType: BlockTypeDefinition;
|
|
536
|
+
export const dividerBlockType: BlockTypeDefinition;
|
|
537
|
+
export const calloutBlockType: BlockTypeDefinition;
|
|
538
|
+
export const blockquoteBlockType: BlockTypeDefinition;
|
|
539
|
+
export const codeBlockType: BlockTypeDefinition;
|
|
540
|
+
export const toggleHeadingBlockType: BlockTypeDefinition;
|
|
541
|
+
export const buttonBlockType: BlockTypeDefinition;
|
|
542
|
+
export const embedBlockType: BlockTypeDefinition;
|
|
543
|
+
export const canvasBlockType: BlockTypeDefinition;
|
|
544
|
+
|
|
545
|
+
export function registerBuiltInInlineTypes(inlineRegistry: InlineRegistry): void;
|
|
546
|
+
export function registerInlineTypes(inlineRegistry: InlineRegistry, types: Record<string, InlineTypeDefinition>): void;
|
|
547
|
+
export const TABLE_SELECT_INLINE_TYPES: Record<string, InlineTypeDefinition>;
|
|
548
|
+
|
|
549
|
+
export const selectInlineType: InlineTypeDefinition;
|
|
550
|
+
export const dateInlineType: InlineTypeDefinition;
|
|
551
|
+
export const checkboxInlineType: InlineTypeDefinition;
|
|
552
|
+
export const tableSelectInlineType: InlineTypeDefinition;
|
|
553
|
+
export const emojiInlineType: InlineTypeDefinition;
|
|
554
|
+
|
|
555
|
+
// ---------------------------------------------------------------------------
|
|
556
|
+
// react/ — provider, core hooks
|
|
557
|
+
// ---------------------------------------------------------------------------
|
|
558
|
+
|
|
559
|
+
export interface EditorProviderProps {
|
|
560
|
+
store: EditorStore | History;
|
|
561
|
+
registry: BlockRegistry;
|
|
562
|
+
inlineRegistry?: InlineRegistry | null;
|
|
563
|
+
history?: History | null;
|
|
564
|
+
className?: string;
|
|
565
|
+
style?: CSSProperties;
|
|
566
|
+
theme?: 'default' | 'none';
|
|
567
|
+
getBlockClassName?: (block: Block) => string | undefined;
|
|
568
|
+
/** Current user's id for authoring comments through the built-in comment UI -- see useCommentAuthorId. */
|
|
569
|
+
commentAuthorId?: string;
|
|
570
|
+
children?: ReactNode;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
export function EditorProvider(props: EditorProviderProps): ReactElement;
|
|
574
|
+
export function useEditorStore(): EditorStore | History;
|
|
575
|
+
export function useBlockRegistry(): BlockRegistry;
|
|
576
|
+
export function useInlineRegistry(): InlineRegistry | null;
|
|
577
|
+
export function useWholeDocumentSelection(): [boolean, (value: boolean) => void];
|
|
578
|
+
export function useBlockRangeSelection(): [string[], (ids: string[]) => void];
|
|
579
|
+
export function useSelectedBlock(): [string | null, (id: string | null) => void];
|
|
580
|
+
export function usePreviewMode(): [boolean, (value: boolean) => void];
|
|
581
|
+
/** The commentAuthorId passed to EditorProvider/NoteloomEditor, or undefined if not configured -- see NoteloomEditorProps.commentAuthorId. */
|
|
582
|
+
export function useCommentAuthorId(): string | undefined;
|
|
583
|
+
export function useFieldTypeEditor(): {
|
|
584
|
+
editingFieldTypeId: string | null;
|
|
585
|
+
openFieldTypeEditor: (id: string | null) => void;
|
|
586
|
+
closeFieldTypeEditor: () => void;
|
|
587
|
+
};
|
|
588
|
+
export function useBlockClassName(baseClassName: string | undefined, block: Block): string | undefined;
|
|
589
|
+
|
|
590
|
+
export function injectDefaultStyles(): void;
|
|
591
|
+
|
|
592
|
+
export function useBlock(id: string): Block | undefined;
|
|
593
|
+
export function useRun(id: string): Run | undefined;
|
|
594
|
+
export function useFieldTypes(): FieldType[];
|
|
595
|
+
|
|
596
|
+
export interface UseHistoryResult {
|
|
597
|
+
canUndo: boolean;
|
|
598
|
+
canRedo: boolean;
|
|
599
|
+
undo: () => boolean;
|
|
600
|
+
redo: () => boolean;
|
|
601
|
+
getHistoryLog: () => HistoryLogEntry[];
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export function useHistory(): UseHistoryResult | null;
|
|
605
|
+
|
|
606
|
+
export function usePersistedDocument(options: {
|
|
607
|
+
store: EditorStore | History;
|
|
608
|
+
docId: string;
|
|
609
|
+
debounceMs?: number;
|
|
610
|
+
onError?: (error: unknown) => void;
|
|
611
|
+
}): { isLoaded: boolean };
|
|
612
|
+
|
|
613
|
+
export function usePresence(session: CollabSession | null | undefined): Map<string, Record<string, unknown>>;
|
|
614
|
+
|
|
615
|
+
export function useServiceWorkerUpdate(): { updateAvailable: boolean; applyUpdate: () => void };
|
|
616
|
+
|
|
617
|
+
export function useVoiceTyping(options?: Record<string, unknown>): Record<string, unknown>;
|
|
618
|
+
export const VoicePermissionModal: ComponentType<Record<string, unknown>>;
|
|
619
|
+
export const VoiceListeningIndicator: ComponentType<Record<string, unknown>>;
|
|
620
|
+
export function useCaretRect(...args: unknown[]): unknown;
|
|
621
|
+
export function listVoiceCommands(): Array<{ phrase: string; description: string }>;
|
|
622
|
+
|
|
623
|
+
export function useBlockChildren(parentId: string): string[];
|
|
624
|
+
|
|
625
|
+
export interface ClipboardHandlers {
|
|
626
|
+
onCopy: (event: ClipboardEvent<HTMLElement>) => void;
|
|
627
|
+
onCut: (event: ClipboardEvent<HTMLElement>) => void;
|
|
628
|
+
onPaste: (event: ClipboardEvent<HTMLElement>) => void;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
export function useClipboardHandlers(): ClipboardHandlers;
|
|
632
|
+
export function useEditorKeyboardShortcuts(containerRef: RefObject<HTMLElement | null>): void;
|
|
633
|
+
|
|
634
|
+
export const BlockRenderer: ComponentType<{ id: string }>;
|
|
635
|
+
export const BlockErrorBoundary: ComponentType<{ children?: ReactNode }>;
|
|
636
|
+
export const BlockChildren: ComponentType<{ parentId: string; isTopLevel?: boolean }>;
|
|
637
|
+
export const BlockGutterRow: ComponentType<Record<string, unknown>>;
|
|
638
|
+
export const BlockRangeActionMenu: ComponentType<Record<string, unknown>>;
|
|
639
|
+
export function useBlockRangeDrag(containerRef: RefObject<HTMLElement | null>): void;
|
|
640
|
+
export function useCoarsePointer(): boolean;
|
|
641
|
+
export function useVirtualKeyboardInset(): number;
|
|
642
|
+
export const MobileActionBar: ComponentType<{ containerRef: RefObject<HTMLElement | null> }>;
|
|
643
|
+
export const MobileBlockPickerSheet: ComponentType<Record<string, unknown>>;
|
|
644
|
+
export const MobileBlockOptionsSheet: ComponentType<Record<string, unknown>>;
|
|
645
|
+
export const EditableBlockContent: ComponentType<Record<string, unknown>>;
|
|
646
|
+
export const Modal: ComponentType<{ isOpen?: boolean; onClose?: () => void; children?: ReactNode; [key: string]: unknown }>;
|
|
647
|
+
export const Select: ComponentType<Record<string, unknown>>;
|
|
648
|
+
export const EditorTrailingSpace: ComponentType<Record<string, unknown>>;
|
|
649
|
+
|
|
650
|
+
// ---------------------------------------------------------------------------
|
|
651
|
+
// clipboard/
|
|
652
|
+
// ---------------------------------------------------------------------------
|
|
653
|
+
|
|
654
|
+
export interface CapturedSubtree {
|
|
655
|
+
rootId: string;
|
|
656
|
+
blocks: Block[];
|
|
657
|
+
runs: Run[];
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
export interface RemappedSubtree {
|
|
661
|
+
block: Block;
|
|
662
|
+
runs: Run[];
|
|
663
|
+
subtreeBlocks: Block[];
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
export const APP_MIME: string;
|
|
667
|
+
export function serializeBlockRange(
|
|
668
|
+
store: EditorStore | History,
|
|
669
|
+
registry: BlockRegistry,
|
|
670
|
+
blockIds: string[],
|
|
671
|
+
inlineRegistry?: InlineRegistry,
|
|
672
|
+
): { html: string; text: string; json: string };
|
|
673
|
+
/** Read-only capture of one block + its descendants, with original ids intact — see also captureBlockTemplate for capturing several sibling roots at once. */
|
|
674
|
+
export function captureSubtree(store: EditorStore | History, rootId: string): CapturedSubtree;
|
|
675
|
+
/** Gives a captured subtree fresh ids, ready to insert elsewhere without colliding with existing content. */
|
|
676
|
+
export function remapSubtreeIds(captured: CapturedSubtree): RemappedSubtree;
|
|
677
|
+
export function deserializeClipboard(...args: unknown[]): unknown;
|
|
678
|
+
export function walkDomToBlocks(...args: unknown[]): unknown;
|
|
679
|
+
export function textToParagraphs(...args: unknown[]): unknown;
|
|
680
|
+
/** Returns a JSON *string* (pretty-printed by default) — parse it (`JSON.parse`) to get back a plain `{ version, rootId, blocks, runs }` object usable as `useEditor({ doc })`. */
|
|
681
|
+
export function exportDocumentJSON(store: EditorStore | History, options?: { pretty?: boolean }): string;
|
|
682
|
+
export function exportDocumentHTML(store: EditorStore | History, registry: BlockRegistry): string;
|
|
683
|
+
export function exportDocumentText(store: EditorStore | History, registry: BlockRegistry): string;
|
|
684
|
+
export function exportDocumentSimpleJSON(store: EditorStore | History, registry: BlockRegistry, inlineRegistry: InlineRegistry): unknown;
|
|
685
|
+
export function importDocumentSimpleJSON(json: unknown, registry: BlockRegistry, inlineRegistry: InlineRegistry): DocumentJSON;
|
|
686
|
+
export const DocumentExportButton: ComponentType<Record<string, unknown>>;
|
|
687
|
+
|
|
688
|
+
// ---------------------------------------------------------------------------
|
|
689
|
+
// commands/
|
|
690
|
+
// ---------------------------------------------------------------------------
|
|
691
|
+
|
|
692
|
+
export interface CommandMenuTriggerState {
|
|
693
|
+
isOpen: boolean;
|
|
694
|
+
rect: { top: number; left: number; bottom: number; right: number } | null;
|
|
695
|
+
commands: unknown[];
|
|
696
|
+
runId: string | null;
|
|
697
|
+
selectCommand: (command: unknown) => void;
|
|
698
|
+
close: () => void;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export interface SlashMenuProps {
|
|
702
|
+
isOpen: boolean;
|
|
703
|
+
rect: CommandMenuTriggerState['rect'];
|
|
704
|
+
commands: unknown[];
|
|
705
|
+
runId: string | null;
|
|
706
|
+
onSelect: (command: unknown) => void;
|
|
707
|
+
onClose: () => void;
|
|
708
|
+
menuId?: string;
|
|
709
|
+
ariaLabel?: string;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
export const SlashMenu: ComponentType<SlashMenuProps>;
|
|
713
|
+
export function useSlashMenuTrigger(containerRef: RefObject<HTMLElement | null>): CommandMenuTriggerState;
|
|
714
|
+
export function useEmojiMenuTrigger(containerRef: RefObject<HTMLElement | null>): CommandMenuTriggerState;
|
|
715
|
+
export function useAtMenuTrigger(containerRef: RefObject<HTMLElement | null>): CommandMenuTriggerState;
|
|
716
|
+
|
|
717
|
+
export interface FloatingToolbarProps {
|
|
718
|
+
isOpen: boolean;
|
|
719
|
+
rect: CommandMenuTriggerState['rect'];
|
|
720
|
+
kind: string | null;
|
|
721
|
+
selection: unknown;
|
|
722
|
+
crossSelection: unknown;
|
|
723
|
+
marks: Record<string, unknown>;
|
|
724
|
+
store: EditorStore | History;
|
|
725
|
+
/** Adds a Comment button (same-block selections only) that calls this with the CommentRange under the current selection. Takes priority over commentAuthorId's built-in composer when both are given. */
|
|
726
|
+
onComment?: (range: CommentRange) => void;
|
|
727
|
+
/** Adds a Comment button using a built-in inline composer (addComment(store, range, {authorId: commentAuthorId, text})) instead of onComment -- see NoteloomEditorProps.commentAuthorId. */
|
|
728
|
+
commentAuthorId?: string;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export const FloatingToolbar: ComponentType<FloatingToolbarProps>;
|
|
732
|
+
export function useFloatingToolbarTrigger(containerRef: RefObject<HTMLElement | null>): {
|
|
733
|
+
isOpen: boolean;
|
|
734
|
+
rect: CommandMenuTriggerState['rect'];
|
|
735
|
+
kind: string | null;
|
|
736
|
+
selection: unknown;
|
|
737
|
+
crossSelection: unknown;
|
|
738
|
+
marks: Record<string, unknown>;
|
|
739
|
+
};
|
|
740
|
+
export function useTextFormattingActions(...args: unknown[]): unknown;
|
|
741
|
+
|
|
742
|
+
// ---------------------------------------------------------------------------
|
|
743
|
+
// blocks/table/
|
|
744
|
+
// ---------------------------------------------------------------------------
|
|
745
|
+
|
|
746
|
+
export function insertRowAfter(...args: unknown[]): unknown;
|
|
747
|
+
export function deleteRow(...args: unknown[]): unknown;
|
|
748
|
+
export function insertColumnAfter(...args: unknown[]): unknown;
|
|
749
|
+
export function deleteColumn(...args: unknown[]): unknown;
|
|
750
|
+
export function renameColumn(...args: unknown[]): unknown;
|
|
751
|
+
export function setColumnType(...args: unknown[]): unknown;
|
|
752
|
+
export function setColumnOptions(...args: unknown[]): unknown;
|
|
753
|
+
export function setColumnWidth(...args: unknown[]): unknown;
|
|
754
|
+
export function resolveColumns(...args: unknown[]): unknown;
|
|
755
|
+
export function createDefaultColumns(...args: unknown[]): unknown;
|
|
756
|
+
export function createCellForColumn(...args: unknown[]): unknown;
|
|
757
|
+
export function convertRunToType(...args: unknown[]): unknown;
|
|
758
|
+
export function blankRunForType(...args: unknown[]): unknown;
|
|
759
|
+
export const COLUMN_TYPES: Record<string, string>;
|
|
760
|
+
export const DEFAULT_COLUMN_TYPE: string;
|
|
761
|
+
export const DEFAULT_COLUMN_WIDTH: number;
|
|
762
|
+
export const MIN_COLUMN_WIDTH: number;
|
|
763
|
+
export const TableHeaderRow: ComponentType<Record<string, unknown>>;
|
|
764
|
+
|
|
765
|
+
// ---------------------------------------------------------------------------
|
|
766
|
+
// inline/, react/ selection & shared block actions
|
|
767
|
+
// ---------------------------------------------------------------------------
|
|
768
|
+
|
|
769
|
+
export function toggleMarkOnRunRange(...args: unknown[]): unknown;
|
|
770
|
+
export function toggleMarkOverSelection(...args: unknown[]): unknown;
|
|
771
|
+
export function toggleMarkOverBlockRange(...args: unknown[]): unknown;
|
|
772
|
+
export function setMarksOverSelection(...args: unknown[]): unknown;
|
|
773
|
+
export function setMarksOverBlockRange(...args: unknown[]): unknown;
|
|
774
|
+
export function getMarksSummaryOverSelection(...args: unknown[]): Record<string, unknown>;
|
|
775
|
+
export function getMarksSummaryOverBlockRange(...args: unknown[]): Record<string, unknown>;
|
|
776
|
+
export function deleteRunRangeInBlock(...args: unknown[]): unknown;
|
|
777
|
+
export function deleteOverBlockRange(...args: unknown[]): unknown;
|
|
778
|
+
export function deleteEntireDocument(...args: unknown[]): unknown;
|
|
779
|
+
export function resolveRunSelection(...args: unknown[]): unknown;
|
|
780
|
+
export function resolveMultiRunSelection(...args: unknown[]): unknown;
|
|
781
|
+
export function resolveCrossBlockSelection(...args: unknown[]): unknown;
|
|
782
|
+
export function resolveCollapsedCaret(...args: unknown[]): unknown;
|
|
783
|
+
export function isEntireBlockSelected(...args: unknown[]): boolean;
|
|
784
|
+
export function focusRunEnd(runId: string): void;
|
|
785
|
+
export function focusRunStart(runId: string): void;
|
|
786
|
+
export function focusRunAtOffset(runId: string, offset: number): void;
|
|
787
|
+
export function ensureRootNonEmpty(store: EditorStore | History): void;
|
|
788
|
+
export function duplicateBlock(...args: unknown[]): unknown;
|
|
789
|
+
export function moveBlockUp(...args: unknown[]): unknown;
|
|
790
|
+
export function moveBlockDown(...args: unknown[]): unknown;
|
|
791
|
+
export function deleteBlockAndFocusSibling(...args: unknown[]): unknown;
|
|
792
|
+
export function deleteBlockRange(...args: unknown[]): unknown;
|
|
793
|
+
export function moveBlockRangeUp(...args: unknown[]): unknown;
|
|
794
|
+
export function moveBlockRangeDown(...args: unknown[]): unknown;
|
|
795
|
+
export function isEntireBlockRangeHidden(...args: unknown[]): boolean;
|
|
796
|
+
export function setBlockRangeHidden(...args: unknown[]): unknown;
|
|
797
|
+
export function reorderBlockRangeFromStore(...args: unknown[]): unknown;
|
|
798
|
+
export function copyBlockRangeToClipboard(...args: unknown[]): unknown;
|
|
799
|
+
|
|
800
|
+
// ---------------------------------------------------------------------------
|
|
801
|
+
// inlineTypes/customSelect/ — user-authored custom field types
|
|
802
|
+
// ---------------------------------------------------------------------------
|
|
803
|
+
|
|
804
|
+
export function createSelectFieldType(options: Record<string, unknown>): InlineTypeDefinition;
|
|
805
|
+
export function registerStoredFieldTypes(inlineRegistry: InlineRegistry, fieldTypes: FieldType[]): void;
|
|
806
|
+
export function useRegisterFieldTypes(inlineRegistry: InlineRegistry, fieldTypes: FieldType[]): void;
|
|
807
|
+
export const FieldTypeEditorModal: ComponentType<Record<string, unknown>>;
|
|
808
|
+
|
|
809
|
+
// ---------------------------------------------------------------------------
|
|
810
|
+
// react/useEditor.js, react/NoteloomEditor.jsx — the simplified entry point
|
|
811
|
+
// ---------------------------------------------------------------------------
|
|
812
|
+
|
|
813
|
+
export interface UseEditorOptions {
|
|
814
|
+
/** Starting document; defaults to one empty paragraph. */
|
|
815
|
+
doc?: DocumentJSON;
|
|
816
|
+
/** true (default): store is undo/redo-aware (a History instance). false: a plain EditorStore. */
|
|
817
|
+
history?: boolean;
|
|
818
|
+
/** Replaces registerBuiltInBlocks for an opt-in subset of block types. */
|
|
819
|
+
registerBlocks?: (registry: BlockRegistry) => void;
|
|
820
|
+
/** Replaces registerBuiltInInlineTypes for an opt-in subset of inline types. */
|
|
821
|
+
registerInlineTypes?: (inlineRegistry: InlineRegistry) => void;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
export interface UseEditorResult {
|
|
825
|
+
store: History | EditorStore;
|
|
826
|
+
registry: BlockRegistry;
|
|
827
|
+
inlineRegistry: InlineRegistry;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/** The one-call path to a working editor — see the README's Quick start. */
|
|
831
|
+
export function useEditor(options?: UseEditorOptions): UseEditorResult;
|
|
832
|
+
|
|
833
|
+
export interface NoteloomEditorProps {
|
|
834
|
+
editor: UseEditorResult;
|
|
835
|
+
className?: string;
|
|
836
|
+
style?: CSSProperties;
|
|
837
|
+
theme?: 'default' | 'none';
|
|
838
|
+
getBlockClassName?: (block: Block) => string | undefined;
|
|
839
|
+
/** Adds a Comment button to the floating format toolbar, fully host-controlled — see FloatingToolbarProps.onComment. */
|
|
840
|
+
onComment?: (range: CommentRange) => void;
|
|
841
|
+
/** Current user's id -- enables the whole built-in comments UI (floating toolbar composer, click/hover popover on existing highlights, CommentsPanel) with no host UI code. Ignored by the floating toolbar's button when onComment is also given. */
|
|
842
|
+
commentAuthorId?: string;
|
|
843
|
+
/** Renders CommentsPanel (right-side, Notion/Google Docs-style thread list) automatically. */
|
|
844
|
+
showCommentsPanel?: boolean;
|
|
845
|
+
children?: ReactNode;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/** Renders the object useEditor() returned, with every built-in interaction wired up. */
|
|
849
|
+
export function NoteloomEditor(props: NoteloomEditorProps): ReactElement;
|