Skip to content

Commit 4f5325f

Browse files
committed
feat: add isChangeOrigin and isUndoRedoOperation to yjs-remote event
1 parent 5132e66 commit 4f5325f

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

examples/07-collaboration/01-partykit/App.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,12 @@ export default function App() {
3030
});
3131

3232
// Renders the editor instance.
33-
return <BlockNoteView editor={editor} />;
33+
return (
34+
<BlockNoteView
35+
editor={editor}
36+
onChange={(e, { getChanges }) => {
37+
console.log(getChanges());
38+
}}
39+
/>
40+
);
3441
}

packages/core/src/api/nodeUtil.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ export type BlockChangeSource =
8787
/**
8888
* When an event is triggered by a remote user, the source is "remote".
8989
*/
90-
type: "remote";
90+
type: "yjs-remote";
91+
/**
92+
* Whether the change is from this client or another client.
93+
*/
94+
isChangeOrigin: boolean;
95+
/**
96+
* Whether the change is an undo or redo operation.
97+
*/
98+
isUndoRedoOperation: boolean;
9199
};
92100

93101
export type BlocksChanged<
@@ -147,7 +155,11 @@ export function getBlocksChangedByTransaction<
147155
type: transaction.getMeta("history$").redo ? "redo" : "undo",
148156
};
149157
} else if (transaction.getMeta("y-sync$")) {
150-
source = { type: "remote" };
158+
source = {
159+
type: "yjs-remote",
160+
isChangeOrigin: transaction.getMeta("y-sync$").isChangeOrigin,
161+
isUndoRedoOperation: transaction.getMeta("y-sync$").isUndoRedoOperation,
162+
};
151163
}
152164

153165
const changes: BlocksChanged<BSchema, ISchema, SSchema> = [];

0 commit comments

Comments
 (0)