Skip to content

Commit c2b8a0e

Browse files
committed
Add optional file ID to document state
1 parent a3c01bc commit c2b8a0e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

jupyter_ydoc/ybasedoc.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ def path(self) -> Optional[str]:
109109
"""
110110
return self._ystate.get("path")
111111

112+
@property
113+
def file_id(self) -> Optional[str]:
114+
"""
115+
Returns document's file ID.
116+
117+
:return: Document's file ID.
118+
:rtype: Optional[str]
119+
"""
120+
return self._ystate.get("file_id")
121+
112122
@path.setter
113123
def path(self, value: str) -> None:
114124
"""
@@ -119,6 +129,16 @@ def path(self, value: str) -> None:
119129
"""
120130
self._ystate["path"] = value
121131

132+
@file_id.setter
133+
def file_id(self, value: str) -> None:
134+
"""
135+
Sets document's file ID.
136+
137+
:param value: Document's file ID.
138+
:type value: str
139+
"""
140+
self._ystate["file_id"] = value
141+
122142
@abstractmethod
123143
def get(self) -> Any:
124144
"""

jupyter_ydoc/ynotebook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def set(self, value: Dict) -> None:
229229
# clear document
230230
self._ymeta.clear()
231231
self._ycells.clear()
232-
for key in [k for k in self._ystate.keys() if k not in ("dirty", "path")]:
232+
for key in [k for k in self._ystate.keys() if k not in ("dirty", "path", "file_id")]:
233233
del self._ystate[key]
234234

235235
# initialize document

0 commit comments

Comments
 (0)