Wiki source code of Front-End Collaboration API

Last modified by Manuel Leduc on 2026/02/05 17:22

Show last authors
1 == CollaborationInitializer ==
2
3 {{code language="typescript"}}
4 /**
5 * Holds properties of an collaboration. It's provider, the document held by the provider, and a provide resolved on
6 * the initialized is ready.
7 * @since 0.20
8 */
9 type CollaborationInitializer = {
10 /**
11 * The provider, can be of arbitrary type.
12 */
13 // eslint-disable-next-line @typescript-eslint/no-explicit-any
14 provider: any;
15 /**
16 * The yjs document held by the provider.
17 */
18 doc: Doc;
19 /**
20 * The promise must be resolved once the provider is connected and ready.
21 */
22 initialized: Promise<unknown>;
23 };
24
25 {{/code}}
26
27 == CollaborationManager ==
28
29 {{code language="typescript"}}
30 /**
31 * The manager for a given collaboration provider (e.g., hocuspocus, or y-websocket).
32 * @since 0.20
33 */
34 interface CollaborationManager {
35 /**
36 * A lazy initializer for a collaboration initializer. We proceed that way to allow the collaboration provider to
37 * be resolved and assigned outside the editor, but to be effectively initialized inside the editor, where
38 * access to the internal editor structure is available.
39 */
40 get(): Promise<() => CollaborationInitializer>;
41
42 /**
43 * The current status.
44 */
45 status(): Ref<Status>;
46
47 /**
48 * The list of currently connected users.
49 */
50 users(): Ref<User[]>;
51 }
52
53 {{/code}}
54
55 == CollaborationManagerProvider ==
56
57 {{code language="typescript"}}
58 /**
59 * Dynamically resolves a CollaborationManager based on the configuration.
60 *
61 * @since 0.20
62 */
63 export interface CollaborationManagerProvider {
64 /**
65 * @returns the resolved collaboration manager
66 */
67 get(): CollaborationManager;
68 }
69
70 {{/code}}
71
72 == User ==
73
74 {{code language="typescript"}}
75 /**
76 * Mandatory information for a user connected to a realtime session.
77 *
78 * @since 0.20
79 */
80 export type User = {
81 user: {
82 name: string;
83 color: string;
84 };
85 clientId: string;
86 };
87
88 {{/code}}

Get Connected