@jupyter/ydoc
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -59,4 +59,7 @@ /** | ||
* 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`) | ||
*/ | ||
transact(f: () => void): void; | ||
transact(f: () => void, undoable?: boolean): void; | ||
} | ||
@@ -63,0 +66,0 @@ /** |
@@ -204,2 +204,5 @@ import type * as nbformat from '@jupyterlab/nbformat'; | ||
* 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`) | ||
*/ | ||
@@ -206,0 +209,0 @@ transact(f: () => void, undoable?: boolean): void; |
@@ -375,17 +375,19 @@ /* ----------------------------------------------------------------------------- | ||
} | ||
this._ymetadata.delete(key); | ||
const jupyter = this.getMetadata('jupyter'); | ||
if (key === 'collapsed' && jupyter) { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { outputs_hidden, ...others } = jupyter; | ||
if (Object.keys(others).length === 0) { | ||
this._ymetadata.delete('jupyter'); | ||
this.transact(() => { | ||
this._ymetadata.delete(key); | ||
const jupyter = this.getMetadata('jupyter'); | ||
if (key === 'collapsed' && jupyter) { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { outputs_hidden, ...others } = jupyter; | ||
if (Object.keys(others).length === 0) { | ||
this._ymetadata.delete('jupyter'); | ||
} | ||
else { | ||
this._ymetadata.set('jupyter', others); | ||
} | ||
} | ||
else { | ||
this._ymetadata.set('jupyter', others); | ||
else if (key === 'jupyter') { | ||
this._ymetadata.delete('collapsed'); | ||
} | ||
} | ||
else if (key === 'jupyter') { | ||
this._ymetadata.delete('collapsed'); | ||
} | ||
}, false); | ||
} | ||
@@ -443,3 +445,3 @@ getMetadata(key) { | ||
} | ||
}); | ||
}, false); | ||
} | ||
@@ -460,3 +462,3 @@ else { | ||
} | ||
}); | ||
}, false); | ||
} | ||
@@ -479,9 +481,12 @@ } | ||
* 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`) | ||
*/ | ||
transact(f, undoable = true) { | ||
this.notebook && undoable | ||
? this.notebook.transact(f) | ||
: this.ymodel.doc == null | ||
!this.notebook || this.notebook.disableDocumentWideUndoRedo | ||
? this.ymodel.doc == null | ||
? f() | ||
: this.ymodel.doc.transact(f, this); | ||
: this.ymodel.doc.transact(f, undoable ? this : null) | ||
: this.notebook.transact(f, undoable); | ||
} | ||
@@ -520,19 +525,21 @@ /** | ||
case 'update': | ||
const newValue = this._ymetadata.get(key); | ||
const oldValue = change.oldValue; | ||
let equal = true; | ||
if (typeof oldValue == 'object' && typeof newValue == 'object') { | ||
equal = JSONExt.deepEqual(oldValue, newValue); | ||
{ | ||
const newValue = this._ymetadata.get(key); | ||
const oldValue = change.oldValue; | ||
let equal = true; | ||
if (typeof oldValue == 'object' && typeof newValue == 'object') { | ||
equal = JSONExt.deepEqual(oldValue, newValue); | ||
} | ||
else { | ||
equal = oldValue === newValue; | ||
} | ||
if (!equal) { | ||
this._metadataChanged.emit({ | ||
key, | ||
type: 'change', | ||
oldValue, | ||
newValue | ||
}); | ||
} | ||
} | ||
else { | ||
equal = oldValue === newValue; | ||
} | ||
if (!equal) { | ||
this._metadataChanged.emit({ | ||
key, | ||
type: 'change', | ||
oldValue, | ||
newValue | ||
}); | ||
} | ||
break; | ||
@@ -608,3 +615,3 @@ } | ||
this.ymodel.set('execution_count', count); | ||
}); | ||
}, false); | ||
} | ||
@@ -716,3 +723,3 @@ } | ||
} | ||
}); | ||
}, false); | ||
} | ||
@@ -719,0 +726,0 @@ /** |
{ | ||
"name": "@jupyter/ydoc", | ||
"version": "0.3.3", | ||
"version": "0.3.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
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
131720
3036