@jupyter/ydoc
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -10,3 +10,3 @@ import { JSONObject, JSONValue } from '@lumino/coreutils'; | ||
export declare class YDocument<T extends DocumentChange> implements ISharedDocument { | ||
constructor(); | ||
constructor(options?: YDocument.IOptions); | ||
/** | ||
@@ -17,17 +17,17 @@ * Creates a standalone YDocument | ||
/** | ||
* YJS document | ||
* YJS document. | ||
*/ | ||
readonly ydoc: Y.Doc; | ||
get ydoc(): Y.Doc; | ||
/** | ||
* Shared state | ||
*/ | ||
readonly ystate: Y.Map<any>; | ||
get ystate(): Y.Map<any>; | ||
/** | ||
* YJS document undo manager | ||
*/ | ||
readonly undoManager: Y.UndoManager; | ||
get undoManager(): Y.UndoManager; | ||
/** | ||
* Shared awareness | ||
*/ | ||
readonly awareness: Awareness; | ||
get awareness(): Awareness; | ||
/** | ||
@@ -96,4 +96,17 @@ * The changed signal. | ||
protected _changed: Signal<this, T>; | ||
private _ydoc; | ||
private _ystate; | ||
private _undoManager; | ||
private _awareness; | ||
private _isDisposed; | ||
private _disposed; | ||
} | ||
declare namespace YDocument { | ||
interface IOptions { | ||
/** | ||
* The optional YJS document for YDocument. | ||
*/ | ||
ydoc?: Y.Doc; | ||
} | ||
} | ||
export {}; |
@@ -13,23 +13,5 @@ /* ----------------------------------------------------------------------------- | ||
export class YDocument { | ||
constructor() { | ||
constructor(options) { | ||
var _a; | ||
/** | ||
* YJS document | ||
*/ | ||
this.ydoc = new Y.Doc(); | ||
/** | ||
* Shared state | ||
*/ | ||
this.ystate = this.ydoc.getMap('state'); | ||
/** | ||
* YJS document undo manager | ||
*/ | ||
this.undoManager = new Y.UndoManager([], { | ||
trackedOrigins: new Set([this]), | ||
doc: this.ydoc | ||
}); | ||
/** | ||
* Shared awareness | ||
*/ | ||
this.awareness = new Awareness(this.ydoc); | ||
/** | ||
* Handle a change to the ystate. | ||
@@ -54,3 +36,10 @@ */ | ||
this._disposed = new Signal(this); | ||
this.ystate.observe(this.onStateChanged); | ||
this._ydoc = (_a = options === null || options === void 0 ? void 0 : options.ydoc) !== null && _a !== void 0 ? _a : new Y.Doc(); | ||
this._ystate = this._ydoc.getMap('state'); | ||
this._undoManager = new Y.UndoManager([], { | ||
trackedOrigins: new Set([this]), | ||
doc: this._ydoc | ||
}); | ||
this._awareness = new Awareness(this._ydoc); | ||
this._ystate.observe(this.onStateChanged); | ||
} | ||
@@ -64,2 +53,26 @@ /** | ||
/** | ||
* YJS document. | ||
*/ | ||
get ydoc() { | ||
return this._ydoc; | ||
} | ||
/** | ||
* Shared state | ||
*/ | ||
get ystate() { | ||
return this._ystate; | ||
} | ||
/** | ||
* YJS document undo manager | ||
*/ | ||
get undoManager() { | ||
return this._undoManager; | ||
} | ||
/** | ||
* Shared awareness | ||
*/ | ||
get awareness() { | ||
return this._awareness; | ||
} | ||
/** | ||
* The changed signal. | ||
@@ -66,0 +79,0 @@ */ |
{ | ||
"name": "@jupyter/ydoc", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Jupyter document structures for collaborative editing using YJS", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130747
3023