@jupyter/ydoc
Advanced tools
Comparing version 2.1.3 to 2.1.4
@@ -63,4 +63,5 @@ /** | ||
* @param undoable Whether to track the change in the action history or not (default `true`) | ||
* @param origin Transaction origin | ||
*/ | ||
transact(f: () => void, undoable?: boolean): void; | ||
transact(f: () => void, undoable?: boolean, origin?: any): void; | ||
} | ||
@@ -67,0 +68,0 @@ /** |
@@ -207,4 +207,6 @@ import type * as nbformat from '@jupyterlab/nbformat'; | ||
* @param undoable Whether to track the change in the action history or not (default `true`) | ||
* @param origin Transaction origin; if set to 'silent-change' and {@link undoable} is false, | ||
* it won't emit model {@link changed}. | ||
*/ | ||
transact(f: () => void, undoable?: boolean): void; | ||
transact(f: () => void, undoable?: boolean, origin?: any): void; | ||
/** | ||
@@ -294,3 +296,3 @@ * Extract changes from YJS events | ||
*/ | ||
updateOutputs(start: number, end: number, outputs?: Array<nbformat.IOutput>): void; | ||
updateOutputs(start: number, end: number, outputs?: Array<nbformat.IOutput>, origin?: any): void; | ||
/** | ||
@@ -297,0 +299,0 @@ * Serialize the model to JSON. |
@@ -115,4 +115,6 @@ /* ----------------------------------------------------------------------------- | ||
*/ | ||
this._modelObserver = (events) => { | ||
this._changed.emit(this.getChanges(events)); | ||
this._modelObserver = (events, transaction) => { | ||
if (transaction.origin !== 'silent-change') { | ||
this._changed.emit(this.getChanges(events)); | ||
} | ||
}; | ||
@@ -482,8 +484,10 @@ this._metadataChanged = new Signal(this); | ||
* @param undoable Whether to track the change in the action history or not (default `true`) | ||
* @param origin Transaction origin; if set to 'silent-change' and {@link undoable} is false, | ||
* it won't emit model {@link changed}. | ||
*/ | ||
transact(f, undoable = true) { | ||
transact(f, undoable = true, origin = null) { | ||
!this.notebook || this.notebook.disableDocumentWideUndoRedo | ||
? this.ymodel.doc == null | ||
? f() | ||
: this.ymodel.doc.transact(f, undoable ? this : null) | ||
: this.ymodel.doc.transact(f, undoable ? this : origin) | ||
: this.notebook.transact(f, undoable); | ||
@@ -649,3 +653,3 @@ } | ||
*/ | ||
updateOutputs(start, end, outputs = []) { | ||
updateOutputs(start, end, outputs = [], origin = null) { | ||
const fin = end < this._youtputs.length ? end - start : this._youtputs.length - start; | ||
@@ -655,3 +659,3 @@ this.transact(() => { | ||
this._youtputs.insert(start, outputs); | ||
}, false); | ||
}, false, origin); | ||
} | ||
@@ -658,0 +662,0 @@ /** |
@@ -87,4 +87,8 @@ import { JSONObject, JSONValue } from '@lumino/coreutils'; | ||
* document are bundled into a single event. | ||
* | ||
* @param f Transaction to execute | ||
* @param undoable Whether to track the change in the action history or not (default `true`) | ||
* @param origin Transaction origin | ||
*/ | ||
transact(f: () => void, undoable?: boolean): void; | ||
transact(f: () => void, undoable?: boolean, origin?: any): void; | ||
/** | ||
@@ -91,0 +95,0 @@ * Handle a change to the ystate. |
@@ -162,7 +162,11 @@ /* ----------------------------------------------------------------------------- | ||
* document are bundled into a single event. | ||
* | ||
* @param f Transaction to execute | ||
* @param undoable Whether to track the change in the action history or not (default `true`) | ||
* @param origin Transaction origin | ||
*/ | ||
transact(f, undoable = true) { | ||
this.ydoc.transact(f, undoable ? this : null); | ||
transact(f, undoable = true, origin = null) { | ||
this.ydoc.transact(f, undoable ? this : origin); | ||
} | ||
} | ||
//# sourceMappingURL=ydocument.js.map |
{ | ||
"name": "@jupyter/ydoc", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"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
Sorry, the diff of this file is not supported yet
133884
3089