Skip to content

Commit

Permalink
Add forkID document attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Feb 27, 2024
1 parent 83681d6 commit 20be1d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions javascript/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ export interface ISharedDocument extends ISharedBase {
* @param forkId The fork ID to add to the document
*/
addFork(forkId: string): void;

/**
* The document fork ID
*/
forkId: string;
}

/**
Expand Down
7 changes: 7 additions & 0 deletions javascript/src/ydocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export abstract class YDocument<T extends DocumentChange>
{
constructor(options?: YDocument.IOptions) {
this._ydoc = options?.ydoc ?? new Y.Doc();
this.forkId = options?.forkId ?? 'root';

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

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

/**
Expand All @@ -239,5 +241,10 @@ export namespace YDocument {
* The optional YJS document for YDocument.
*/
ydoc?: Y.Doc;

/**
* The document fork ID, defaults to 'root'.
*/
forkId?: string;
}
}

0 comments on commit 20be1d2

Please sign in to comment.