@jupyter/ydoc
Advanced tools
Comparing version 0.3.0-a5 to 0.3.0-a6
@@ -337,5 +337,5 @@ /** | ||
/** | ||
* The language preference for the model. | ||
* The content of the notebook. | ||
*/ | ||
languagePreference?: string; | ||
data?: Partial<nbformat.INotebookContent>; | ||
} | ||
@@ -342,0 +342,0 @@ } |
@@ -7,4 +7,4 @@ import type * as nbformat from '@jupyterlab/nbformat'; | ||
import type { CellChange, IMapChange, ISharedAttachmentsCell, ISharedBaseCell, ISharedCodeCell, ISharedMarkdownCell, ISharedRawCell, SharedCell } from './api.js'; | ||
import { IYText } from './ytext'; | ||
import { YNotebook } from './ynotebook'; | ||
import { IYText } from './ytext.js'; | ||
import { YNotebook } from './ynotebook.js'; | ||
/** | ||
@@ -11,0 +11,0 @@ * Cell type. |
@@ -516,8 +516,17 @@ /* ----------------------------------------------------------------------------- | ||
case 'update': | ||
if (!JSONExt.deepEqual(change.oldValue, this._ymetadata.get(key))) { | ||
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, | ||
newValue: this._ymetadata.get(key), | ||
oldValue: change.oldValue, | ||
type: 'change' | ||
type: 'change', | ||
oldValue, | ||
newValue | ||
}); | ||
@@ -524,0 +533,0 @@ } |
import * as Y from 'yjs'; | ||
import type { FileChange, ISharedFile, ISharedText } from './api.js'; | ||
import { IYText } from './ytext'; | ||
import { YDocument } from './ydocument'; | ||
import { IYText } from './ytext.js'; | ||
import { YDocument } from './ydocument.js'; | ||
/** | ||
@@ -6,0 +6,0 @@ * Shareable text file. |
@@ -5,3 +5,3 @@ /* ----------------------------------------------------------------------------- | ||
|----------------------------------------------------------------------------*/ | ||
import { YDocument } from './ydocument'; | ||
import { YDocument } from './ydocument.js'; | ||
/** | ||
@@ -8,0 +8,0 @@ * Shareable text file. |
@@ -6,4 +6,4 @@ import type * as nbformat from '@jupyterlab/nbformat'; | ||
import type { IMapChange, ISharedNotebook, NotebookChange, SharedCell } from './api.js'; | ||
import { YDocument } from './ydocument'; | ||
import { YBaseCell, YCellType } from './ycell'; | ||
import { YDocument } from './ydocument.js'; | ||
import { YBaseCell, YCellType } from './ycell.js'; | ||
/** | ||
@@ -28,3 +28,3 @@ * Shared implementation of the Shared Document types. | ||
*/ | ||
constructor(options?: ISharedNotebook.IOptions); | ||
constructor(options?: Omit<ISharedNotebook.IOptions, 'data'>); | ||
/** | ||
@@ -31,0 +31,0 @@ * Creates a standalone YNotebook |
@@ -8,4 +8,4 @@ /* ----------------------------------------------------------------------------- | ||
import * as Y from 'yjs'; | ||
import { YDocument } from './ydocument'; | ||
import { createCell, createCellModelFromSharedType } from './ycell'; | ||
import { YDocument } from './ydocument.js'; | ||
import { createCell, createCellModelFromSharedType } from './ycell.js'; | ||
/** | ||
@@ -62,8 +62,17 @@ * Shared implementation of the Shared Document types. | ||
case 'update': | ||
if (!JSONExt.deepEqual(change.oldValue, ymetadata.get(key))) { | ||
const newValue = 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: change.oldValue, | ||
newValue: ymetadata.get(key) | ||
oldValue, | ||
newValue | ||
}); | ||
@@ -168,13 +177,13 @@ } | ||
static create(options = {}) { | ||
var _a, _b; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j; | ||
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); | ||
const data = { | ||
cells: (_c = (_b = options.data) === null || _b === void 0 ? void 0 : _b.cells) !== null && _c !== void 0 ? _c : [], | ||
nbformat: (_e = (_d = options.data) === null || _d === void 0 ? void 0 : _d.nbformat) !== null && _e !== void 0 ? _e : 4, | ||
nbformat_minor: (_g = (_f = options.data) === null || _f === void 0 ? void 0 : _f.nbformat_minor) !== null && _g !== void 0 ? _g : 5, | ||
metadata: (_j = (_h = options.data) === null || _h === void 0 ? void 0 : _h.metadata) !== null && _j !== void 0 ? _j : {} | ||
}; | ||
ynotebook.fromJSON(data); | ||
return ynotebook; | ||
@@ -181,0 +190,0 @@ } |
{ | ||
"name": "@jupyter/ydoc", | ||
"version": "0.3.0-a5", | ||
"version": "0.3.0-a6", | ||
"type": "module", | ||
@@ -31,6 +31,7 @@ "description": "Jupyter document structures for collaborative editing using YJS", | ||
"eslint:check": "eslint --ext .js,.jsx,.ts,.tsx --cache .", | ||
"lint": "yarn prettier && yarn eslint", | ||
"lint": "yarn integrity && yarn prettier && yarn eslint", | ||
"lint:check": "yarn prettier:check && yarn eslint:check", | ||
"prettier": "prettier --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json}\"", | ||
"prettier:check": "prettier --check \"**/*{.ts,.tsx,.js,.jsx,.css,.json}\"", | ||
"integrity": "yarn tsc-esm-fix --src='src' --ext='.js'", | ||
"test": "jest", | ||
@@ -60,5 +61,7 @@ "test:cov": "jest --collect-coverage", | ||
"prettier": "^2.6.0", | ||
"process": "0.11.10", | ||
"rimraf": "^3.0.0", | ||
"typedoc": "^0.23.21", | ||
"typescript": "^4.8.0" | ||
"typescript": "^4.8.0", | ||
"tsc-esm-fix": "^2.20.0" | ||
}, | ||
@@ -65,0 +68,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
129183
3017
14