Skip to content

Commit 4084e2b

Browse files
committed
Add README
1 parent 749aac8 commit 4084e2b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Automerge + Codemirror
2+
3+
This plugin adds collaborative editing to codemirror using `automerge-repo`.
4+
5+
## Example
6+
7+
```typescript
8+
import { Repo } from "@automerge/automerge-repo";
9+
import { automergeSyncPlugin } from "@automerge/automerge-codemirror";
10+
import { EditorView } from "@codemirror/view"
11+
import { basicSetup } from "codemirror"
12+
13+
// Setup a repo and create a doc handle. In practice you'll probably get a
14+
// DocHandle by loading it from a document URL
15+
const repo = new Repo(..)
16+
const doc = repo.create({text: ""})
17+
18+
// Setup the codemirror view
19+
const container = document.createElement("div")
20+
const view = new EditorView({
21+
doc: handle.docSync()!.text,
22+
extensions: [
23+
basicSetup,
24+
automergeSyncPlugin({
25+
handle,
26+
path: ["text"],
27+
}),
28+
],
29+
parent: container,
30+
})
31+
```
32+

0 commit comments

Comments
 (0)