Skip to content

Commit fc539cd

Browse files
committed
fix
1 parent 465f232 commit fc539cd

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/editor/src/app/documentRenderers/richtext/RichTextRenderer.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const RichTextRenderer: React.FC<Props> = observer((props) => {
2929
const frameClientIds = new Set<number>();
3030

3131
// eslint-disable-next-line @typescript-eslint/no-explicit-any
32-
props.document.awareness.on("change", (changes: any, origin: any) => {
32+
props.document.awareness?.on("change", (changes: any, origin: any) => {
3333
if (origin !== provider) {
3434
return;
3535
}
@@ -44,11 +44,13 @@ const RichTextRenderer: React.FC<Props> = observer((props) => {
4444

4545
const removePresence = () => {
4646
// remove cursor from awareness when we navigate away
47-
awarenessProtocol.removeAwarenessStates(
48-
props.document.awareness,
49-
[...frameClientIds],
50-
"window unload",
51-
);
47+
if (props.document.awareness) {
48+
awarenessProtocol.removeAwarenessStates(
49+
props.document.awareness,
50+
[...frameClientIds],
51+
"window unload",
52+
);
53+
}
5254
};
5355

5456
window.addEventListener("beforeunload", removePresence);

0 commit comments

Comments
 (0)