-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Description
I'm trying to create a new shared model for an extension; for that reason, I need to import yjs. The problem comes from yjs that need only one copy of the library, and we have two (one in JupyterLab and another in the extension).
The solution would be to add yjs to resolutions in JupyterLab's package.json.
Another solution would be to add yjs to jupyterlab.sharedPackages
in those core extension that uses yjs. Still, yjs is used in core packages, not in extensions (docprovider, docregistry and shared-models), and I think JupyterLab only deduplicates dependencies from extensions (core packages don't have jupyterlab.sharedPackages
).
The second solution implicates to modify webpack.config to get shared packages from core packages.
Expected behavior
Import yjs on extensions.
Context
I have an error with yjs coming from:
https://github.com/QuantStack/jupyterlab-drawio/blob/f66b1c571b9b4007a7b08a0bd42c4e3c967cc916/src/model.ts#L167
It looks like there are two instances, one coming from JupyterLab and another from the extension.
Browser Output
9795.87a9ff4f3c3919e683d2.js?v=87a9ff4f3c3919e683d2:1 Uncaught Error: Unexpected content type in insert operation at 9795.87a9ff4f3c3919e683d2.js?v=87a9ff4f3c3919e683d2:1 at Array.forEach () at Vs (9795.87a9ff4f3c3919e683d2.js?v=87a9ff4f3c3919e683d2:1) at Ps (9795.87a9ff4f3c3919e683d2.js?v=87a9ff4f3c3919e683d2:1) at 9795.87a9ff4f3c3919e683d2.js?v=87a9ff4f3c3919e683d2:1 at Yn (9795.87a9ff4f3c3919e683d2.js?v=87a9ff4f3c3919e683d2:1) at mr.insert (9795.87a9ff4f3c3919e683d2.js?v=87a9ff4f3c3919e683d2:1) at new Q (646.3107e1e3e0432c8636f0.js?v=3107e1e3e0432c8636f0:1) at Function.create (646.3107e1e3e0432c8636f0.js?v=3107e1e3e0432c8636f0:1) at new z (646.3107e1e3e0432c8636f0.js?v=3107e1e3e0432c8636f0:1)
This line returns false, being ydoc
an instance coming from JupyterLab and Y.XmlFragment
a class imported from Yjs in the extension.
this.ydoc.getXmlFragment('root') instanceof Y.XmlFragment