loro-prosemirror
v0.2.0
Published
Prosemirror Binding for Loro
Downloads
1,857
Maintainers
Readme
Prosemirror Binding for Loro
- Sync document state with Loro
- Sync cursors with Loro's Awareness and Cursor
- Undo/Redo in collaborative editing
- 🎨 Try it online
import {
CursorAwareness,
LoroCursorPlugin,
LoroSyncPlugin,
LoroUndoPlugin,
undo,
redo,
} from "loro-prosemirror";
import { LoroDoc } from "loro-crdt";
const doc = new LoroDoc();
const awareness = new CursorAwareness(doc.peerIdStr);
const plugins = [
...pmPlugins,
LoroSyncPlugin({ doc }),
LoroUndoPlugin({ doc }),
keymap({
"Mod-z": undo,
"Mod-y": redo,
"Mod-Shift-z": redo,
}),
LoroCursorPlugin(awareness, {}),
];
const editor = new EditorView(editorDom, {
state: EditorState.create({ doc, plugins }),
});
https://github.com/loro-dev/prosemirror/assets/18425020/d0f01760-b76c-43b5-b7f7-b0b224130d9d