Skip to content

Commit

Permalink
docs: add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zxch3n committed Jun 6, 2024
1 parent 9e4fa94 commit 4a83b39
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
# loro-prosemirror
# Prosemirror Binding for Loro

- Sync document state with Loro
- Sync cursors with Loro's Awareness and [Cursor](https://loro.dev/docs/tutorial/cursor)
- Undo/Redo in collaborative editing

```ts
import {
CursorAwareness,
LoroCursorPlugin,
LoroSyncPlugin,
LoroUndoPlugin,
undo,
redo,
} from "loro-prosemirror";
import { Loro } from "loro-crdt";

const doc = new Loro();
const awareness = new CursorAwareness(doc.peerIdStr);
const plugins = [
...pmPlugins,
LoroSyncPlugin({ doc }),
LoroUndoPlugin({ doc }),
keymap({
"Mod-z": state => undo(state, () => {}),
"Mod-y": state => redo(state, () => {}),
"Mod-Shift-z": state => redo(state, () => {}),
}),
LoroCursorPlugin(awareness, {}),
];
const editor = new EditorView(editorDom, {
state: EditorState.create({ doc, plugins }),
});
```


0 comments on commit 4a83b39

Please sign in to comment.