Skip to content

Commit 691f42f

Browse files
committed
Add forkID document attribute
1 parent 4239d09 commit 691f42f

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 @@ interface ISharedDocumentNoSource 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

@@ -257,6 +258,7 @@ export abstract class YDocument<T extends DocumentChange>
257258
private _isDisposed = false;
258259
private _disposed = new Signal<this, void>(this);
259260
private _providers: { [key: string]: IDocumentProvider };
261+
public forkId: string;
260262
}
261263

262264
/**
@@ -271,5 +273,10 @@ export namespace YDocument {
271273
* The optional YJS document for YDocument.
272274
*/
273275
ydoc?: Y.Doc;
276+
277+
/**
278+
* The document fork ID, defaults to 'root'.
279+
*/
280+
forkId?: string;
274281
}
275282
}

0 commit comments

Comments
 (0)