Skip to content

Commit fb09c48

Browse files
Removes YMap for attachements (#77)
* Attachements are not a YMap in the frontend. * Don't set attachments if there are none Co-authored-by: David Brochart <[email protected]>
1 parent d08ee43 commit fb09c48

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

jupyter_ydoc/ydoc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def get_cell(self, index: int) -> Dict[str, Any]:
9696
del cell["id"]
9797
if (
9898
"attachments" in cell
99-
and cell["cell_type"] in ["raw", "markdown"]
99+
and cell["cell_type"] in ("raw", "markdown")
100100
and not cell["attachments"]
101101
):
102102
del cell["attachments"]
@@ -123,7 +123,8 @@ def create_ycell(self, value: Dict[str, Any]) -> None:
123123
cell["metadata"] = Y.YMap(cell.get("metadata", {}))
124124

125125
if cell_type in ("raw", "markdown"):
126-
cell["attachments"] = Y.YMap(cell.get("attachments", {}))
126+
if "attachments" in cell and not cell["attachments"]:
127+
del cell["attachments"]
127128
elif cell_type == "code":
128129
cell["outputs"] = Y.YArray(cell.get("outputs", []))
129130

0 commit comments

Comments
 (0)