mirror of
https://github.com/outline/outline.git
synced 2026-11-24 23:00:18 +03:00
* fix: Clicking Edit scrolls to the top of the document * fix: Restore scroll after node views render * fix: Switch to editing without redrawing the document * fix: Keep Yjs undo working after switching to editing
40 lines
802 B
TypeScript
40 lines
802 B
TypeScript
import {
|
|
yUndoPlugin,
|
|
undo,
|
|
redo,
|
|
undoCommand,
|
|
redoCommand,
|
|
} from "y-prosemirror";
|
|
import Extension from "@shared/editor/lib/Extension";
|
|
|
|
/**
|
|
* Undo and redo for collaborative documents, backed by the Yjs undo manager.
|
|
* Must be registered after the Multiplayer extension, whose sync plugin it
|
|
* depends on. It is not created in read-only mode, so the undo manager is
|
|
* created fresh when the editor becomes editable.
|
|
*/
|
|
export class MultiplayerUndo extends Extension {
|
|
get name() {
|
|
return "multiplayerUndo";
|
|
}
|
|
|
|
get plugins() {
|
|
return [yUndoPlugin()];
|
|
}
|
|
|
|
commands() {
|
|
return {
|
|
undo: () => undo,
|
|
redo: () => redo,
|
|
};
|
|
}
|
|
|
|
keys() {
|
|
return {
|
|
"Mod-z": undoCommand,
|
|
"Mod-y": redoCommand,
|
|
"Shift-Mod-z": redoCommand,
|
|
};
|
|
}
|
|
}
|