Skip to content

Commit ff25e22

Browse files
committed
Add forkID document attribute
1 parent f2bf387 commit ff25e22

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

javascript/src/api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ export interface ISharedDocument extends ISharedBase {
157157
* @param forkId The fork ID to add to the document
158158
*/
159159
addFork(forkId: string): void;
160+
161+
/**
162+
* The document fork ID
163+
*/
164+
forkId: string;
160165
}
161166

162167
/**

javascript/src/ydocument.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export abstract class YDocument<T extends DocumentChange>
1717
{
1818
constructor(options?: YDocument.IOptions) {
1919
this._ydoc = options?.ydoc ?? new Y.Doc();
20+
this.forkId = options?.forkId ?? 'root';
2021

2122
this._ystate = this._ydoc.getMap('state');
2223

@@ -225,6 +226,7 @@ export abstract class YDocument<T extends DocumentChange>
225226
private _isDisposed = false;
226227
private _disposed = new Signal<this, void>(this);
227228
private _providers: { [key: string]: IDocumentProvider };
229+
public forkId: string;
228230
}
229231

230232
/**
@@ -239,5 +241,10 @@ export namespace YDocument {
239241
* The optional YJS document for YDocument.
240242
*/
241243
ydoc?: Y.Doc;
244+
245+
/**
246+
* The document fork ID, defaults to 'root'.
247+
*/
248+
forkId?: string;
242249
}
243250
}

0 commit comments

Comments
 (0)