From bc29be1f486e90a234be064dd3f249b0060668c7 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Mon, 24 Oct 2022 15:50:34 +0200 Subject: [PATCH] Add path document attribute --- jupyter_ydoc/ydoc.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jupyter_ydoc/ydoc.py b/jupyter_ydoc/ydoc.py index 0063feb..eba88bf 100644 --- a/jupyter_ydoc/ydoc.py +++ b/jupyter_ydoc/ydoc.py @@ -39,6 +39,15 @@ def dirty(self, value: bool) -> None: with self._ydoc.begin_transaction() as t: self._ystate.set(t, "dirty", value) + @property + def path(self) -> None: + return self._ystate.get("path") + + @path.setter + def path(self, value: str) -> None: + with self._ydoc.begin_transaction() as t: + self._ystate.set(t, "path", value) + @abstractmethod def get(self): pass @@ -184,7 +193,7 @@ def set(self, value): 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 != "dirty"]: + for key in [k for k in self._ystate if k not in ("dirty", "path")]: self._ystate.pop(t, key) # initialize document