diff --git a/plugins/yjs/fps_yjs/routes.py b/plugins/yjs/fps_yjs/routes.py index 1ba97afb..56852885 100644 --- a/plugins/yjs/fps_yjs/routes.py +++ b/plugins/yjs/fps_yjs/routes.py @@ -181,6 +181,7 @@ async def serve(self, websocket: YWebsocket, permissions) -> None: file_path = await self.contents.file_id_manager.get_path(file_id) logger.info(f"Opening collaboration room: {websocket.path} ({file_path})") document = YDOCS.get(file_type, YFILE)(room.ydoc) + document.file_id = file_id self.documents[websocket.path] = document async with self.lock: model = await self.contents.read_content(file_path, True, file_format) diff --git a/plugins/yjs/fps_yjs/ydocs/ybasedoc.py b/plugins/yjs/fps_yjs/ydocs/ybasedoc.py index 8b68dad4..3d75d35e 100644 --- a/plugins/yjs/fps_yjs/ydocs/ybasedoc.py +++ b/plugins/yjs/fps_yjs/ydocs/ybasedoc.py @@ -51,6 +51,14 @@ def path(self) -> Optional[str]: def path(self, value: str) -> None: self._ystate["path"] = value + @property + def file_id(self) -> Optional[str]: + return self._ystate.get("file_id") + + @file_id.setter + def file_id(self, value: str) -> None: + self._ystate["file_id"] = value + @abstractmethod def get(self) -> Any: ... diff --git a/plugins/yjs/fps_yjs/ydocs/ynotebook.py b/plugins/yjs/fps_yjs/ydocs/ynotebook.py index 65cafabb..0cadd698 100644 --- a/plugins/yjs/fps_yjs/ydocs/ynotebook.py +++ b/plugins/yjs/fps_yjs/ydocs/ynotebook.py @@ -125,7 +125,7 @@ def set(self, value: Dict) -> None: # clear document self._ymeta.clear() self._ycells.clear() - for key in [k for k in self._ystate.keys() if k not in ("dirty", "path")]: + for key in [k for k in self._ystate.keys() if k not in ("dirty", "path", "file_id")]: del self._ystate[key] # initialize document