From 9fde6ede08c7bdada6adc84c8530e9e518187469 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Tue, 22 Oct 2024 19:06:28 +0200 Subject: [PATCH] Set collaborative attribute to False in Jupyterlite (#525) * Set collaborative attribute to False in Jupyterlite This has the side effect of fixing the saving of files in JupyterLite for now * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Apply suggestions from code review Co-authored-by: Duc Trung Le * It's true that it's not false --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Duc Trung Le --- packages/schema/src/model.ts | 3 ++- python/jupytercad_core/src/jcadplugin/modelfactory.ts | 3 ++- python/jupytercad_core/src/stepplugin/modelfactory.ts | 3 ++- python/jupytercad_core/src/stlplugin/modelfactory.ts | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/schema/src/model.ts b/packages/schema/src/model.ts index d5ccf20d..55839787 100644 --- a/packages/schema/src/model.ts +++ b/packages/schema/src/model.ts @@ -40,7 +40,8 @@ export class JupyterCadModel implements IJupyterCadModel { } }; - readonly collaborative = true; + readonly collaborative = + document.querySelectorAll('[data-jupyter-lite-root]')[0] === undefined; get sharedModel(): IJupyterCadDoc { return this._sharedModel; diff --git a/python/jupytercad_core/src/jcadplugin/modelfactory.ts b/python/jupytercad_core/src/jcadplugin/modelfactory.ts index 00275647..430b91fe 100644 --- a/python/jupytercad_core/src/jcadplugin/modelfactory.ts +++ b/python/jupytercad_core/src/jcadplugin/modelfactory.ts @@ -19,7 +19,8 @@ export class JupyterCadJcadModelFactory /** * Whether the model is collaborative or not. */ - readonly collaborative = true; + readonly collaborative = + document.querySelectorAll('[data-jupyter-lite-root]')[0] === undefined; /** * The name of the model. diff --git a/python/jupytercad_core/src/stepplugin/modelfactory.ts b/python/jupytercad_core/src/stepplugin/modelfactory.ts index 2484b3d6..713ade13 100644 --- a/python/jupytercad_core/src/stepplugin/modelfactory.ts +++ b/python/jupytercad_core/src/stepplugin/modelfactory.ts @@ -11,7 +11,8 @@ export class JupyterCadStepModelFactory /** * Whether the model is collaborative or not. */ - readonly collaborative = true; + readonly collaborative = + document.querySelectorAll('[data-jupyter-lite-root]')[0] === undefined; /** * The name of the model. diff --git a/python/jupytercad_core/src/stlplugin/modelfactory.ts b/python/jupytercad_core/src/stlplugin/modelfactory.ts index 1a3596db..756c9d8c 100644 --- a/python/jupytercad_core/src/stlplugin/modelfactory.ts +++ b/python/jupytercad_core/src/stlplugin/modelfactory.ts @@ -11,7 +11,8 @@ export class JupyterCadStlModelFactory /** * Whether the model is collaborative or not. */ - readonly collaborative = true; + readonly collaborative = + document.querySelectorAll('[data-jupyter-lite-root]')[0] === undefined; /** * The name of the model.