@jupyter/ydoc
Advanced tools
Comparing version 0.3.0-a2 to 0.3.0-a3
@@ -33,2 +33,39 @@ /** | ||
/** | ||
* A factory interface for creating `ISharedDocument` objects. | ||
*/ | ||
export interface IFactory { | ||
/** | ||
* Create a new `ISharedDocument` instance. | ||
*/ | ||
createNew(options: IFactory.IOptions): ISharedDocument; | ||
} | ||
/** | ||
* The namespace for `IFactory`. | ||
*/ | ||
export declare namespace IFactory { | ||
/** | ||
* The options used to instantiate a ISharedDocument | ||
*/ | ||
interface IOptions { | ||
/** | ||
* The path of the file. | ||
*/ | ||
path: string; | ||
/** | ||
* The format of the document. | ||
*/ | ||
format: string; | ||
/** | ||
* The content type of the document. | ||
*/ | ||
contentType: string; | ||
/** | ||
* Wether the document is collaborative or not. | ||
* | ||
* The default value is `true`. | ||
*/ | ||
collaborative?: boolean; | ||
} | ||
} | ||
/** | ||
* ISharedBase defines common operations that can be performed on any shared object. | ||
@@ -298,2 +335,6 @@ */ | ||
disableDocumentWideUndoRedo?: boolean; | ||
/** | ||
* The language preference for the model. | ||
*/ | ||
languagePreference?: string; | ||
} | ||
@@ -300,0 +341,0 @@ } |
@@ -34,3 +34,3 @@ import type * as nbformat from '@jupyterlab/nbformat'; | ||
*/ | ||
static create(): YNotebook; | ||
static create(options?: ISharedNotebook.IOptions): YNotebook; | ||
/** | ||
@@ -37,0 +37,0 @@ * YJS map for the notebook metadata |
@@ -165,5 +165,14 @@ /* ----------------------------------------------------------------------------- | ||
*/ | ||
static create() { | ||
const ynotebook = new YNotebook(); | ||
ynotebook.ymeta.set('metadata', new Y.Map()); | ||
static create(options = {}) { | ||
var _a, _b; | ||
const ynotebook = new YNotebook({ | ||
disableDocumentWideUndoRedo: (_a = options.disableDocumentWideUndoRedo) !== null && _a !== void 0 ? _a : false | ||
}); | ||
const ymetadata = new Y.Map(); | ||
ymetadata.set('language_info', { name: (_b = options.languagePreference) !== null && _b !== void 0 ? _b : '' }); | ||
ymetadata.set('kernelspec', { | ||
name: '', | ||
display_name: '' | ||
}); | ||
ynotebook.ymeta.set('metadata', ymetadata); | ||
return ynotebook; | ||
@@ -370,3 +379,3 @@ } | ||
else { | ||
if (!JSONExt.deepEqual(this.metadata, metadata)) { | ||
if (!this.metadata || !JSONExt.deepEqual(this.metadata, metadata)) { | ||
const clone = JSONExt.deepCopy(metadata); | ||
@@ -419,3 +428,12 @@ const ymetadata = this.ymeta.get('metadata'); | ||
} | ||
this.metadata = metadata; | ||
if (!this.metadata) { | ||
const ymetadata = new Y.Map(); | ||
for (const [key, value] of Object.entries(metadata)) { | ||
ymetadata.set(key, value); | ||
} | ||
this.ymeta.set('metadata', ymetadata); | ||
} | ||
else { | ||
this.metadata = metadata; | ||
} | ||
const useId = value.nbformat === 4 && value.nbformat_minor >= 5; | ||
@@ -422,0 +440,0 @@ const ycells = value.cells.map(cell => { |
{ | ||
"name": "@jupyter/ydoc", | ||
"version": "0.3.0-a2", | ||
"version": "0.3.0-a3", | ||
"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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
127378
2997
1