diff --git a/jupyter_ydoc/ybasedoc.py b/jupyter_ydoc/ybasedoc.py index 44f9799..a24bf82 100644 --- a/jupyter_ydoc/ybasedoc.py +++ b/jupyter_ydoc/ybasedoc.py @@ -110,6 +110,16 @@ def path(self) -> Optional[str]: """ return self._ystate.get("path") + @property + def file_id(self) -> Optional[str]: + """ + Returns document's file ID. + + :return: Document's file ID. + :rtype: Optional[str] + """ + return self._ystate.get("file_id") + @path.setter def path(self, value: str) -> None: """ @@ -121,6 +131,17 @@ def path(self, value: str) -> None: with self._ydoc.begin_transaction() as t: self._ystate.set(t, "path", value) + @file_id.setter + def file_id(self, value: str) -> None: + """ + Sets document's file ID. + + :param value: Document's file ID. + :type value: str + """ + with self._ydoc.begin_transaction() as t: + self._ystate.set(t, "file_id", value) + @abstractmethod def get(self) -> Any: """ diff --git a/jupyter_ydoc/ynotebook.py b/jupyter_ydoc/ynotebook.py index 47ae466..c7f1af2 100644 --- a/jupyter_ydoc/ynotebook.py +++ b/jupyter_ydoc/ynotebook.py @@ -254,7 +254,7 @@ def set(self, value: Dict) -> None: self._ymeta.pop(t, key) if cells_len: self._ycells.delete_range(t, 0, cells_len) - for key in [k for k in self._ystate if k not in ("dirty", "path")]: + for key in [k for k in self._ystate if k not in ("dirty", "path", "file_id")]: self._ystate.pop(t, key) # initialize document