Files
Tom Moor 03fe74710c fix: Undo/redo events duplicated (#12525)
* fix: Undo/redo events duplicated

* fix: Guard history use
Prevent cross polination of editors

* Remove unused check
2026-05-29 20:04:11 -04:00

30 lines
701 B
TypeScript

import { history, undo, redo } from "prosemirror-history";
import type { Command } from "prosemirror-state";
import type { CommandFactory } from "../lib/Extension";
import Extension from "../lib/Extension";
export default class History extends Extension {
get name() {
return "history";
}
commands(): Record<string, CommandFactory> {
return {
undo: () => undo,
redo: () => redo,
};
}
keys(): Record<string, Command | CommandFactory> {
return {
"Mod-z": () => this.editor.commands.undo(),
"Mod-y": () => this.editor.commands.redo(),
"Shift-Mod-z": () => this.editor.commands.redo(),
};
}
get plugins() {
return [history()];
}
}