diff --git a/jupyter_ydoc/ynotebook.py b/jupyter_ydoc/ynotebook.py index 4a9f4d5..864a79f 100644 --- a/jupyter_ydoc/ynotebook.py +++ b/jupyter_ydoc/ynotebook.py @@ -166,7 +166,12 @@ def create_ycell(self, value: Dict[str, Any]) -> Map: outputs = cell.get("outputs", []) for idx, output in enumerate(outputs): if output.get("output_type") == "stream": - output["text"] = Array(output.get("text", [])) + text = output.get("text", "") + if isinstance(text, str): + ytext = Text(text) + else: + ytext = Text("".join(text)) + output["text"] = ytext outputs[idx] = Map(output) cell["outputs"] = Array(outputs) cell["execution_state"] = "idle" diff --git a/tests/test_pycrdt_yjs.py b/tests/test_pycrdt_yjs.py index e099b3b..bc23b37 100644 --- a/tests/test_pycrdt_yjs.py +++ b/tests/test_pycrdt_yjs.py @@ -90,7 +90,7 @@ async def test_ypy_yjs_1(yws_server, yjs_client): ydoc, Websocket(websocket, room_name) ): output_text = ynotebook.ycells[0]["outputs"][0]["text"] - assert output_text.to_py() == ["Hello,"] + assert output_text.to_py() == "Hello," event = Event() def callback(_event): @@ -101,7 +101,7 @@ def callback(_event): with move_on_after(10): await event.wait() - assert output_text.to_py() == ["Hello,", " World!"] + assert output_text.to_py() == "Hello,", " World!" def test_plotly_renderer():