Skip to content

Commit 4a83b39

Browse files
committed
docs: add readme
1 parent 9e4fa94 commit 4a83b39

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1-
# loro-prosemirror
1+
# Prosemirror Binding for Loro
2+
3+
- Sync document state with Loro
4+
- Sync cursors with Loro's Awareness and [Cursor](https://loro.dev/docs/tutorial/cursor)
5+
- Undo/Redo in collaborative editing
6+
7+
```ts
8+
import {
9+
CursorAwareness,
10+
LoroCursorPlugin,
11+
LoroSyncPlugin,
12+
LoroUndoPlugin,
13+
undo,
14+
redo,
15+
} from "loro-prosemirror";
16+
import { Loro } from "loro-crdt";
17+
18+
const doc = new Loro();
19+
const awareness = new CursorAwareness(doc.peerIdStr);
20+
const plugins = [
21+
...pmPlugins,
22+
LoroSyncPlugin({ doc }),
23+
LoroUndoPlugin({ doc }),
24+
keymap({
25+
"Mod-z": state => undo(state, () => {}),
26+
"Mod-y": state => redo(state, () => {}),
27+
"Mod-Shift-z": state => redo(state, () => {}),
28+
}),
29+
LoroCursorPlugin(awareness, {}),
30+
];
31+
const editor = new EditorView(editorDom, {
32+
state: EditorState.create({ doc, plugins }),
33+
});
34+
```
35+
36+

0 commit comments

Comments
 (0)