@kedataindo/docflow-core 0.0.71 → 0.0.72
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/dist/Collaboration-CGv9OZlB.d.cts +109 -0
- package/dist/Collaboration-CGv9OZlB.d.ts +109 -0
- package/dist/chunk-XJG72F7M.js +140 -0
- package/dist/collab/index.cjs +286 -0
- package/dist/collab/index.d.cts +71 -0
- package/dist/collab/index.d.ts +71 -0
- package/dist/collab/index.js +116 -0
- package/dist/index.cjs +56 -120
- package/dist/index.d.cts +18 -150
- package/dist/index.d.ts +18 -150
- package/dist/index.js +52 -247
- package/package.json +6 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { AnyExtension, Editor, Extension } from '@tiptap/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { WebrtcProvider } from 'y-webrtc';
|
|
5
|
-
import { WebsocketProvider } from 'y-websocket';
|
|
6
|
-
import * as Y from 'yjs';
|
|
2
|
+
import { a as CollaborationSetup } from './Collaboration-CGv9OZlB.cjs';
|
|
3
|
+
export { A as AwarenessState, C as CollaborationOptions, c as collaborationExtensions, b as createCollaboration } from './Collaboration-CGv9OZlB.cjs';
|
|
7
4
|
import { I as ImageUploadHandler, C as CitationPort, A as AIStreamFn, a as AIDraftFn } from './index-BTF6gajh.cjs';
|
|
8
5
|
export { b as AIAction, c as AIActionRequest, d as AICompleteRequest, e as AIConfig, f as AIContextLocation, g as AIDraftCitation, h as AIDraftEvent, i as AIProvider, j as AIProviderFactory, k as AiChatRequestContext, l as Auth, m as CONTEXT_CHAR_CAP, n as CslDate, o as CslItemData, p as CslName, H as HttpKeyStorageUrls, q as ImageUploadResult, K as KeyStorage, L as LOCAL_STORAGE_KEY, O as OpenAICompatibleConfig, S as StreamEvent, r as buildAIPrompt, s as httpKeyStorage, t as localStorageKeyStorage, u as memoryKeyStorage, v as openaiCompatibleProvider, w as toAIStreamFn, x as trimContextAfter, y as trimContextBefore } from './index-BTF6gajh.cjs';
|
|
9
6
|
import { PluginKey } from '@tiptap/pm/state';
|
|
10
7
|
import { Node } from '@tiptap/pm/model';
|
|
8
|
+
import 'y-protocols/awareness';
|
|
9
|
+
import 'y-indexeddb';
|
|
10
|
+
import 'y-webrtc';
|
|
11
|
+
import 'y-websocket';
|
|
12
|
+
import 'yjs';
|
|
11
13
|
|
|
12
14
|
interface ToolbarItem {
|
|
13
15
|
id: string;
|
|
@@ -38,87 +40,6 @@ declare function collectExtensions(plugins: DocsEditorPlugin[]): AnyExtension[];
|
|
|
38
40
|
declare function resolveAction(editor: Editor, action: string, ...args: unknown[]): boolean;
|
|
39
41
|
declare function createActionMap(editor: Editor, plugins: DocsEditorPlugin[]): Record<string, (...args: unknown[]) => boolean>;
|
|
40
42
|
|
|
41
|
-
interface AwarenessState {
|
|
42
|
-
clientId: number;
|
|
43
|
-
user: {
|
|
44
|
-
name: string;
|
|
45
|
-
color: string;
|
|
46
|
-
};
|
|
47
|
-
cursor?: {
|
|
48
|
-
from: number;
|
|
49
|
-
to: number;
|
|
50
|
-
} | null;
|
|
51
|
-
/**
|
|
52
|
-
* Phase 9 PR2 — *present* flag. False when the local user has navigated
|
|
53
|
-
* away from the editor route (the Yjs provider is still alive but the
|
|
54
|
-
* host has gated cursor emission off, per the §6 *\"TOC sidebar orphan
|
|
55
|
-
* wiring\"* / REST-heartbeat scope notes). Peers see this instantly
|
|
56
|
-
* via the awareness `change` event — far faster than the 15s REST
|
|
57
|
-
* heartbeat fallback. Defaults to true when the user is in the editor.
|
|
58
|
-
*/
|
|
59
|
-
present: boolean;
|
|
60
|
-
}
|
|
61
|
-
interface CollaborationOptions {
|
|
62
|
-
room: string;
|
|
63
|
-
provider?: 'webrtc' | 'websocket';
|
|
64
|
-
websocketUrl?: string;
|
|
65
|
-
signaling?: string[];
|
|
66
|
-
user: {
|
|
67
|
-
name: string;
|
|
68
|
-
color: string;
|
|
69
|
-
};
|
|
70
|
-
onAwarenessChange?: (states: AwarenessState[]) => void;
|
|
71
|
-
initialStorageState?: Uint8Array;
|
|
72
|
-
/**
|
|
73
|
-
* Phase 9 PR2 — when false, the local user is treated as
|
|
74
|
-
* out-of-editor: their cursor field is nulled and `present` is false.
|
|
75
|
-
* Default is true (in editor). Toggle at runtime via
|
|
76
|
-
* `setLocalCursorEnabled()` returned from `createCollaboration`.
|
|
77
|
-
*/
|
|
78
|
-
emitCursor?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Phase 9 OF1 — when true, mirror the room's Y.Doc into IndexedDB
|
|
81
|
-
* (`docflow-<room>`) via y-indexeddb so edits survive offline and reload.
|
|
82
|
-
* Reconcile-on-reconnect is plain Yjs merge — no conflict resolution
|
|
83
|
-
* needed. The IndexedDB mirror is NEVER a seed source: the server (or the
|
|
84
|
-
* legacy-JSON seed path) still owns initial state; the mirror only
|
|
85
|
-
* contributes local offline edits via the normal Yjs update exchange.
|
|
86
|
-
*/
|
|
87
|
-
offline?: boolean;
|
|
88
|
-
}
|
|
89
|
-
interface CollaborationSetup {
|
|
90
|
-
ydoc: Y.Doc;
|
|
91
|
-
provider: WebrtcProvider | WebsocketProvider | null;
|
|
92
|
-
awareness: Awareness;
|
|
93
|
-
/**
|
|
94
|
-
* Phase 9 OF1 — y-indexeddb persistence instance, present only when
|
|
95
|
-
* `options.offline` is true. Exposed so hosts/tests can `await
|
|
96
|
-
* persistence.whenSynced` before asserting the mirror contents. Do not
|
|
97
|
-
* use it as a seed source.
|
|
98
|
-
*/
|
|
99
|
-
persistence?: IndexeddbPersistence;
|
|
100
|
-
/**
|
|
101
|
-
* Issue #117 — resolves after BOTH the offline mirror (if `offline`) AND
|
|
102
|
-
* the provider's first sync (if `websocket`) have completed. Hosts MUST
|
|
103
|
-
* `await setup.whenReady` before binding the editor, otherwise the
|
|
104
|
-
* TipTap view can render against the IndexedDB cache before the
|
|
105
|
-
* authoritative server state arrives, briefly showing — and on a
|
|
106
|
-
* disconnected peer potentially re-broadcasting — nodes the server has
|
|
107
|
-
* since deleted. Resolves immediately when neither side applies.
|
|
108
|
-
*/
|
|
109
|
-
whenReady: Promise<void>;
|
|
110
|
-
destroy: () => void;
|
|
111
|
-
/**
|
|
112
|
-
* Phase 9 PR2 — toggle the local cursor emission + present flag.
|
|
113
|
-
* Pass `false` when the editor route unmounts, `true` when it remounts.
|
|
114
|
-
* Triggers an awareness `change` event so peers see the leave/rejoin
|
|
115
|
-
* instantly (no REST-heartbeat lag).
|
|
116
|
-
*/
|
|
117
|
-
setLocalCursorEnabled: (enabled: boolean) => void;
|
|
118
|
-
}
|
|
119
|
-
declare function createCollaboration(options: CollaborationOptions): CollaborationSetup;
|
|
120
|
-
declare function collaborationExtensions(options: CollaborationOptions | CollaborationSetup): AnyExtension[];
|
|
121
|
-
|
|
122
43
|
interface PageSize {
|
|
123
44
|
pageHeight: number;
|
|
124
45
|
pageWidth: number;
|
|
@@ -276,7 +197,16 @@ interface EditorOptions {
|
|
|
276
197
|
plugins?: DocsEditorPlugin[];
|
|
277
198
|
editable?: boolean;
|
|
278
199
|
onUpdate?: (json: object) => void;
|
|
279
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Prebuilt collaboration setup from `await createCollaboration(...)`.
|
|
202
|
+
*
|
|
203
|
+
* A `CollaborationSetup` — never raw `CollaborationOptions` (issue
|
|
204
|
+
* fe-aktifai#230): building a provider is async (lazy-imports of
|
|
205
|
+
* y-webrtc/y-websocket), so `createEditor` cannot construct one itself.
|
|
206
|
+
* When set, history is disabled and the Yjs document is authoritative
|
|
207
|
+
* (local `content` is not seeded).
|
|
208
|
+
*/
|
|
209
|
+
collaboration?: CollaborationSetup;
|
|
280
210
|
getPageMap?: () => Map<number, {
|
|
281
211
|
page: number;
|
|
282
212
|
blockIndex: number;
|
|
@@ -393,66 +323,4 @@ declare function replaceCurrent(editor: Editor, replacement: string): boolean;
|
|
|
393
323
|
/** Replace every match in one transaction (applied back-to-front). */
|
|
394
324
|
declare function replaceAll(editor: Editor, replacement: string): number;
|
|
395
325
|
|
|
396
|
-
|
|
397
|
-
id: string;
|
|
398
|
-
doc: Y.Doc;
|
|
399
|
-
provider: WebsocketProvider | null;
|
|
400
|
-
active: boolean;
|
|
401
|
-
}
|
|
402
|
-
interface SubdocumentProviderOptions {
|
|
403
|
-
/** WebSocket URL for the collaboration server. */
|
|
404
|
-
websocketUrl: string;
|
|
405
|
-
/** Room prefix — subdocuments use `${roomPrefix}/${id}` as room name. */
|
|
406
|
-
roomPrefix: string;
|
|
407
|
-
/** User info for awareness. */
|
|
408
|
-
user: {
|
|
409
|
-
name: string;
|
|
410
|
-
color: string;
|
|
411
|
-
};
|
|
412
|
-
/** Number of subdocuments to keep active (buffer around visible viewport). */
|
|
413
|
-
maxActive?: number;
|
|
414
|
-
/** Called when subdocument state changes (active/deactivated). */
|
|
415
|
-
onStateChange?: (states: SubdocState[]) => void;
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Manages multiple Y.Doc subdocuments under a parent document.
|
|
419
|
-
*
|
|
420
|
-
* Use case: large documents (100+ pages) split into per-section subdocuments.
|
|
421
|
-
* Only active (visible) subdocuments are connected to the network via
|
|
422
|
-
* WebSocketProvider; inactive ones keep local state but stop syncing.
|
|
423
|
-
*
|
|
424
|
-
* Usage:
|
|
425
|
-
* const provider = new SubdocumentProvider({ websocketUrl, roomPrefix, user })
|
|
426
|
-
* provider.createSubdoc('section-1')
|
|
427
|
-
* provider.activate('section-1') // starts syncing
|
|
428
|
-
* provider.deactivate('section-1') // stops syncing
|
|
429
|
-
* const frag = provider.getFragment('section-1') // Y.XmlFragment for editor
|
|
430
|
-
*/
|
|
431
|
-
declare class SubdocumentProvider {
|
|
432
|
-
readonly parentDoc: Y.Doc;
|
|
433
|
-
readonly subdocs: Y.Map<Y.Doc>;
|
|
434
|
-
readonly awareness: Awareness;
|
|
435
|
-
private readonly options;
|
|
436
|
-
private readonly states;
|
|
437
|
-
private readonly activeQueue;
|
|
438
|
-
private readonly parentProvider;
|
|
439
|
-
constructor(options: SubdocumentProviderOptions);
|
|
440
|
-
/** Create a new subdocument. Does NOT activate it. */
|
|
441
|
-
createSubdoc(id: string, initialState?: Uint8Array): Y.Doc;
|
|
442
|
-
/** Activate a subdocument — connects it to the network for live sync. */
|
|
443
|
-
activate(id: string): void;
|
|
444
|
-
/** Deactivate a subdocument — disconnects it from the network. */
|
|
445
|
-
deactivate(id: string): void;
|
|
446
|
-
/** Get the Y.XmlFragment for a subdocument. */
|
|
447
|
-
getFragment(id: string): Y.XmlFragment | null;
|
|
448
|
-
/** Check if a subdocument is currently active (syncing). */
|
|
449
|
-
isActive(id: string): boolean;
|
|
450
|
-
/** Get all subdocument states. */
|
|
451
|
-
getAllStates(): SubdocState[];
|
|
452
|
-
/** Get IDs of all active subdocuments. */
|
|
453
|
-
getActiveIds(): string[];
|
|
454
|
-
/** Destroy all subdocuments and providers. */
|
|
455
|
-
destroy(): void;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
export { AIDraftFn, AIStreamFn, type AwarenessState, BlockAttributesExtension, CitationPort, type ClipboardSource, type CollaborationOptions, type CollaborationSetup, type DocsEditor, type DocsEditorPlugin, EditorContextExtension, type EditorContextOptions, type EditorOptions, FontSizeExtension, ImageUploadHandler, type MonitorMetric, PAGE_SIZES, type PageSize, PaginationPlus, type PaginationPlusOptions, PerformanceMonitor, type PerformanceMonitorOptions, SearchAndReplaceExtension, type SearchMatch, type SearchState, type SlashCommand, type SubdocState, SubdocumentProvider, type SubdocumentProviderOptions, type ToolbarItem, clearSearch, collaborationExtensions, collectExtensions, createActionMap, createCollaboration, createEditor, createPerformanceMonitor, definePlugin, detectClipboardSource, findMatches, getSearchState, normalizeClipboardHTML, replaceAll, replaceCurrent, resolveAction, sanitizePastedHTML, searchAndReplaceKey, searchNext, searchPrev, setSearchQuery };
|
|
326
|
+
export { AIDraftFn, AIStreamFn, BlockAttributesExtension, CitationPort, type ClipboardSource, CollaborationSetup, type DocsEditor, type DocsEditorPlugin, EditorContextExtension, type EditorContextOptions, type EditorOptions, FontSizeExtension, ImageUploadHandler, type MonitorMetric, PAGE_SIZES, type PageSize, PaginationPlus, type PaginationPlusOptions, PerformanceMonitor, type PerformanceMonitorOptions, SearchAndReplaceExtension, type SearchMatch, type SearchState, type SlashCommand, type ToolbarItem, clearSearch, collectExtensions, createActionMap, createEditor, createPerformanceMonitor, definePlugin, detectClipboardSource, findMatches, getSearchState, normalizeClipboardHTML, replaceAll, replaceCurrent, resolveAction, sanitizePastedHTML, searchAndReplaceKey, searchNext, searchPrev, setSearchQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { AnyExtension, Editor, Extension } from '@tiptap/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { WebrtcProvider } from 'y-webrtc';
|
|
5
|
-
import { WebsocketProvider } from 'y-websocket';
|
|
6
|
-
import * as Y from 'yjs';
|
|
2
|
+
import { a as CollaborationSetup } from './Collaboration-CGv9OZlB.js';
|
|
3
|
+
export { A as AwarenessState, C as CollaborationOptions, c as collaborationExtensions, b as createCollaboration } from './Collaboration-CGv9OZlB.js';
|
|
7
4
|
import { I as ImageUploadHandler, C as CitationPort, A as AIStreamFn, a as AIDraftFn } from './index-BTF6gajh.js';
|
|
8
5
|
export { b as AIAction, c as AIActionRequest, d as AICompleteRequest, e as AIConfig, f as AIContextLocation, g as AIDraftCitation, h as AIDraftEvent, i as AIProvider, j as AIProviderFactory, k as AiChatRequestContext, l as Auth, m as CONTEXT_CHAR_CAP, n as CslDate, o as CslItemData, p as CslName, H as HttpKeyStorageUrls, q as ImageUploadResult, K as KeyStorage, L as LOCAL_STORAGE_KEY, O as OpenAICompatibleConfig, S as StreamEvent, r as buildAIPrompt, s as httpKeyStorage, t as localStorageKeyStorage, u as memoryKeyStorage, v as openaiCompatibleProvider, w as toAIStreamFn, x as trimContextAfter, y as trimContextBefore } from './index-BTF6gajh.js';
|
|
9
6
|
import { PluginKey } from '@tiptap/pm/state';
|
|
10
7
|
import { Node } from '@tiptap/pm/model';
|
|
8
|
+
import 'y-protocols/awareness';
|
|
9
|
+
import 'y-indexeddb';
|
|
10
|
+
import 'y-webrtc';
|
|
11
|
+
import 'y-websocket';
|
|
12
|
+
import 'yjs';
|
|
11
13
|
|
|
12
14
|
interface ToolbarItem {
|
|
13
15
|
id: string;
|
|
@@ -38,87 +40,6 @@ declare function collectExtensions(plugins: DocsEditorPlugin[]): AnyExtension[];
|
|
|
38
40
|
declare function resolveAction(editor: Editor, action: string, ...args: unknown[]): boolean;
|
|
39
41
|
declare function createActionMap(editor: Editor, plugins: DocsEditorPlugin[]): Record<string, (...args: unknown[]) => boolean>;
|
|
40
42
|
|
|
41
|
-
interface AwarenessState {
|
|
42
|
-
clientId: number;
|
|
43
|
-
user: {
|
|
44
|
-
name: string;
|
|
45
|
-
color: string;
|
|
46
|
-
};
|
|
47
|
-
cursor?: {
|
|
48
|
-
from: number;
|
|
49
|
-
to: number;
|
|
50
|
-
} | null;
|
|
51
|
-
/**
|
|
52
|
-
* Phase 9 PR2 — *present* flag. False when the local user has navigated
|
|
53
|
-
* away from the editor route (the Yjs provider is still alive but the
|
|
54
|
-
* host has gated cursor emission off, per the §6 *\"TOC sidebar orphan
|
|
55
|
-
* wiring\"* / REST-heartbeat scope notes). Peers see this instantly
|
|
56
|
-
* via the awareness `change` event — far faster than the 15s REST
|
|
57
|
-
* heartbeat fallback. Defaults to true when the user is in the editor.
|
|
58
|
-
*/
|
|
59
|
-
present: boolean;
|
|
60
|
-
}
|
|
61
|
-
interface CollaborationOptions {
|
|
62
|
-
room: string;
|
|
63
|
-
provider?: 'webrtc' | 'websocket';
|
|
64
|
-
websocketUrl?: string;
|
|
65
|
-
signaling?: string[];
|
|
66
|
-
user: {
|
|
67
|
-
name: string;
|
|
68
|
-
color: string;
|
|
69
|
-
};
|
|
70
|
-
onAwarenessChange?: (states: AwarenessState[]) => void;
|
|
71
|
-
initialStorageState?: Uint8Array;
|
|
72
|
-
/**
|
|
73
|
-
* Phase 9 PR2 — when false, the local user is treated as
|
|
74
|
-
* out-of-editor: their cursor field is nulled and `present` is false.
|
|
75
|
-
* Default is true (in editor). Toggle at runtime via
|
|
76
|
-
* `setLocalCursorEnabled()` returned from `createCollaboration`.
|
|
77
|
-
*/
|
|
78
|
-
emitCursor?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Phase 9 OF1 — when true, mirror the room's Y.Doc into IndexedDB
|
|
81
|
-
* (`docflow-<room>`) via y-indexeddb so edits survive offline and reload.
|
|
82
|
-
* Reconcile-on-reconnect is plain Yjs merge — no conflict resolution
|
|
83
|
-
* needed. The IndexedDB mirror is NEVER a seed source: the server (or the
|
|
84
|
-
* legacy-JSON seed path) still owns initial state; the mirror only
|
|
85
|
-
* contributes local offline edits via the normal Yjs update exchange.
|
|
86
|
-
*/
|
|
87
|
-
offline?: boolean;
|
|
88
|
-
}
|
|
89
|
-
interface CollaborationSetup {
|
|
90
|
-
ydoc: Y.Doc;
|
|
91
|
-
provider: WebrtcProvider | WebsocketProvider | null;
|
|
92
|
-
awareness: Awareness;
|
|
93
|
-
/**
|
|
94
|
-
* Phase 9 OF1 — y-indexeddb persistence instance, present only when
|
|
95
|
-
* `options.offline` is true. Exposed so hosts/tests can `await
|
|
96
|
-
* persistence.whenSynced` before asserting the mirror contents. Do not
|
|
97
|
-
* use it as a seed source.
|
|
98
|
-
*/
|
|
99
|
-
persistence?: IndexeddbPersistence;
|
|
100
|
-
/**
|
|
101
|
-
* Issue #117 — resolves after BOTH the offline mirror (if `offline`) AND
|
|
102
|
-
* the provider's first sync (if `websocket`) have completed. Hosts MUST
|
|
103
|
-
* `await setup.whenReady` before binding the editor, otherwise the
|
|
104
|
-
* TipTap view can render against the IndexedDB cache before the
|
|
105
|
-
* authoritative server state arrives, briefly showing — and on a
|
|
106
|
-
* disconnected peer potentially re-broadcasting — nodes the server has
|
|
107
|
-
* since deleted. Resolves immediately when neither side applies.
|
|
108
|
-
*/
|
|
109
|
-
whenReady: Promise<void>;
|
|
110
|
-
destroy: () => void;
|
|
111
|
-
/**
|
|
112
|
-
* Phase 9 PR2 — toggle the local cursor emission + present flag.
|
|
113
|
-
* Pass `false` when the editor route unmounts, `true` when it remounts.
|
|
114
|
-
* Triggers an awareness `change` event so peers see the leave/rejoin
|
|
115
|
-
* instantly (no REST-heartbeat lag).
|
|
116
|
-
*/
|
|
117
|
-
setLocalCursorEnabled: (enabled: boolean) => void;
|
|
118
|
-
}
|
|
119
|
-
declare function createCollaboration(options: CollaborationOptions): CollaborationSetup;
|
|
120
|
-
declare function collaborationExtensions(options: CollaborationOptions | CollaborationSetup): AnyExtension[];
|
|
121
|
-
|
|
122
43
|
interface PageSize {
|
|
123
44
|
pageHeight: number;
|
|
124
45
|
pageWidth: number;
|
|
@@ -276,7 +197,16 @@ interface EditorOptions {
|
|
|
276
197
|
plugins?: DocsEditorPlugin[];
|
|
277
198
|
editable?: boolean;
|
|
278
199
|
onUpdate?: (json: object) => void;
|
|
279
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Prebuilt collaboration setup from `await createCollaboration(...)`.
|
|
202
|
+
*
|
|
203
|
+
* A `CollaborationSetup` — never raw `CollaborationOptions` (issue
|
|
204
|
+
* fe-aktifai#230): building a provider is async (lazy-imports of
|
|
205
|
+
* y-webrtc/y-websocket), so `createEditor` cannot construct one itself.
|
|
206
|
+
* When set, history is disabled and the Yjs document is authoritative
|
|
207
|
+
* (local `content` is not seeded).
|
|
208
|
+
*/
|
|
209
|
+
collaboration?: CollaborationSetup;
|
|
280
210
|
getPageMap?: () => Map<number, {
|
|
281
211
|
page: number;
|
|
282
212
|
blockIndex: number;
|
|
@@ -393,66 +323,4 @@ declare function replaceCurrent(editor: Editor, replacement: string): boolean;
|
|
|
393
323
|
/** Replace every match in one transaction (applied back-to-front). */
|
|
394
324
|
declare function replaceAll(editor: Editor, replacement: string): number;
|
|
395
325
|
|
|
396
|
-
|
|
397
|
-
id: string;
|
|
398
|
-
doc: Y.Doc;
|
|
399
|
-
provider: WebsocketProvider | null;
|
|
400
|
-
active: boolean;
|
|
401
|
-
}
|
|
402
|
-
interface SubdocumentProviderOptions {
|
|
403
|
-
/** WebSocket URL for the collaboration server. */
|
|
404
|
-
websocketUrl: string;
|
|
405
|
-
/** Room prefix — subdocuments use `${roomPrefix}/${id}` as room name. */
|
|
406
|
-
roomPrefix: string;
|
|
407
|
-
/** User info for awareness. */
|
|
408
|
-
user: {
|
|
409
|
-
name: string;
|
|
410
|
-
color: string;
|
|
411
|
-
};
|
|
412
|
-
/** Number of subdocuments to keep active (buffer around visible viewport). */
|
|
413
|
-
maxActive?: number;
|
|
414
|
-
/** Called when subdocument state changes (active/deactivated). */
|
|
415
|
-
onStateChange?: (states: SubdocState[]) => void;
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Manages multiple Y.Doc subdocuments under a parent document.
|
|
419
|
-
*
|
|
420
|
-
* Use case: large documents (100+ pages) split into per-section subdocuments.
|
|
421
|
-
* Only active (visible) subdocuments are connected to the network via
|
|
422
|
-
* WebSocketProvider; inactive ones keep local state but stop syncing.
|
|
423
|
-
*
|
|
424
|
-
* Usage:
|
|
425
|
-
* const provider = new SubdocumentProvider({ websocketUrl, roomPrefix, user })
|
|
426
|
-
* provider.createSubdoc('section-1')
|
|
427
|
-
* provider.activate('section-1') // starts syncing
|
|
428
|
-
* provider.deactivate('section-1') // stops syncing
|
|
429
|
-
* const frag = provider.getFragment('section-1') // Y.XmlFragment for editor
|
|
430
|
-
*/
|
|
431
|
-
declare class SubdocumentProvider {
|
|
432
|
-
readonly parentDoc: Y.Doc;
|
|
433
|
-
readonly subdocs: Y.Map<Y.Doc>;
|
|
434
|
-
readonly awareness: Awareness;
|
|
435
|
-
private readonly options;
|
|
436
|
-
private readonly states;
|
|
437
|
-
private readonly activeQueue;
|
|
438
|
-
private readonly parentProvider;
|
|
439
|
-
constructor(options: SubdocumentProviderOptions);
|
|
440
|
-
/** Create a new subdocument. Does NOT activate it. */
|
|
441
|
-
createSubdoc(id: string, initialState?: Uint8Array): Y.Doc;
|
|
442
|
-
/** Activate a subdocument — connects it to the network for live sync. */
|
|
443
|
-
activate(id: string): void;
|
|
444
|
-
/** Deactivate a subdocument — disconnects it from the network. */
|
|
445
|
-
deactivate(id: string): void;
|
|
446
|
-
/** Get the Y.XmlFragment for a subdocument. */
|
|
447
|
-
getFragment(id: string): Y.XmlFragment | null;
|
|
448
|
-
/** Check if a subdocument is currently active (syncing). */
|
|
449
|
-
isActive(id: string): boolean;
|
|
450
|
-
/** Get all subdocument states. */
|
|
451
|
-
getAllStates(): SubdocState[];
|
|
452
|
-
/** Get IDs of all active subdocuments. */
|
|
453
|
-
getActiveIds(): string[];
|
|
454
|
-
/** Destroy all subdocuments and providers. */
|
|
455
|
-
destroy(): void;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
export { AIDraftFn, AIStreamFn, type AwarenessState, BlockAttributesExtension, CitationPort, type ClipboardSource, type CollaborationOptions, type CollaborationSetup, type DocsEditor, type DocsEditorPlugin, EditorContextExtension, type EditorContextOptions, type EditorOptions, FontSizeExtension, ImageUploadHandler, type MonitorMetric, PAGE_SIZES, type PageSize, PaginationPlus, type PaginationPlusOptions, PerformanceMonitor, type PerformanceMonitorOptions, SearchAndReplaceExtension, type SearchMatch, type SearchState, type SlashCommand, type SubdocState, SubdocumentProvider, type SubdocumentProviderOptions, type ToolbarItem, clearSearch, collaborationExtensions, collectExtensions, createActionMap, createCollaboration, createEditor, createPerformanceMonitor, definePlugin, detectClipboardSource, findMatches, getSearchState, normalizeClipboardHTML, replaceAll, replaceCurrent, resolveAction, sanitizePastedHTML, searchAndReplaceKey, searchNext, searchPrev, setSearchQuery };
|
|
326
|
+
export { AIDraftFn, AIStreamFn, BlockAttributesExtension, CitationPort, type ClipboardSource, CollaborationSetup, type DocsEditor, type DocsEditorPlugin, EditorContextExtension, type EditorContextOptions, type EditorOptions, FontSizeExtension, ImageUploadHandler, type MonitorMetric, PAGE_SIZES, type PageSize, PaginationPlus, type PaginationPlusOptions, PerformanceMonitor, type PerformanceMonitorOptions, SearchAndReplaceExtension, type SearchMatch, type SearchState, type SlashCommand, type ToolbarItem, clearSearch, collectExtensions, createActionMap, createEditor, createPerformanceMonitor, definePlugin, detectClipboardSource, findMatches, getSearchState, normalizeClipboardHTML, replaceAll, replaceCurrent, resolveAction, sanitizePastedHTML, searchAndReplaceKey, searchNext, searchPrev, setSearchQuery };
|