Undo / Redo are not working when collaboration is enabled
@nperez0111 ci sta già lavorando.
Dal 13/1/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Describe the bug
Hello and thank you for the work on BlockNote!
It seems that undo / redo (Ctrl + Z / Ctrl + Y) are not working when the collaboration feature with Yjs is enabled.
When enabling collaboration with a minimal YJsProvider, Ctrl + Z does nothing. If we comment the collaboration part of the config it's working again.
Also, when trying to implement it by hand with the following code, it's still not working:
const undoHandler = useCallback((e: KeyboardEvent) => {
if ((e.metaKey || e.ctrlKey) && (e.key === 'z' || e.key === 'Z')) {
console.log('undo'); // displayed
editor.undo(); // <- NOT WORKING
}
}, []);
useWindowEvent('keydown', undoHandler);
To Reproduce
Here is a minimal reproduction in a sandbox: https://stackblitz.com/edit/github-qp3au5av?file=src%2FApp.tsx
And the code, in case the sandbox is not working:
App.jsx
import '@blocknote/core/fonts/inter.css';
import { BlockNoteView } from '@blocknote/mantine';
import '@blocknote/mantine/style.css';
import { useCreateBlockNote } from '@blocknote/react';
import * as Y from 'yjs';
export default function App() {
const ydoc = new Y.Doc();
const yLoggingProvider = new YProvider(ydoc);
const editor = useCreateBlockNote({
collaboration: {
provider: yLoggingProvider,
fragment: ydoc.getXmlFragment('blocks'),
user: {
name: 'My Username',
color: '#ff0000',
},
// showCursorLabels: 'always',
},
});
// Renders the editor instance using a React component.
return <BlockNoteView editor={editor} />;
}
export class YProvider {
private doc: Y.Doc;
private name: string;
constructor(doc: Y.Doc, name = 'YProvider') {
this.doc = doc;
this.name = name;
this.doc.on('update', this.onLocalUpdate);
console.log(`[${this.name}] provider started`);
}
private onLocalUpdate = (update: Uint8Array, origin: any) => {
Y.applyUpdate(this.doc, update);
};
/**
* Apply a received update from an external source.
* This bypasses the debounce and applies immediately.
*/
public receiveUpdate(update: Uint8Array): void {
Y.applyUpdate(this.doc, update, `${this.name}-external`);
}
public destroy(): void {
this.doc.off('update', this.onLocalUpdate);
}
}
Alternatively, you can try with the official WebrtcProvider as shown in the doc here: https://www.blocknotejs.org/docs/features/collaboration
const provider = new WebrtcProvider("my-document-id", ydoc);
const editor = useCreateBlockNote({
collaboration: {
provider: provider,
// Where to store BlockNote data in the Y.Doc:
fragment: ydoc.getXmlFragment("blocks"),
// Information (name and color) for this user:
user: {
name: "My Username",
color: "#ff0000",
},
// showCursorLabels: 'always',
}
});
It's not working.
Misc
- Node version: 25.2
- Package manager: npm
- Browser: It's not working with multiple browsers
- I'm a sponsor and would appreciate if you could look into this sooner than later 💖
- Lingua principale
- TypeScript
- Stelle
- 10.2k
- Fork
- 772
- Merge medio
- 3g 11h
- PR unite (30g)
- 17
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TypeCellOS/BlockNote
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TypeCellOS/BlockNote#3098 ·
-
Off-By-One `RangeError` Crash and Text Duplication in `StyleManager.editLink` and `deleteLink` Apertaneeds-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
TypeCellOS/BlockNote#3073 ·
-
needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
TypeCellOS/BlockNote#3072 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
TypeCellOS/BlockNote#2949 · 1 commento ·
-
a11y
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
TypeCellOS/BlockNote#2855 ·
Tutte le issue di TypeCellOS/BlockNote
Issue simili
-
comp/dashboard P3 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
NousResearch/hermes-agent#117722 ·
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
-
code-quality refactoring
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
langchain-ai/deepagents#6450 ·