MCPcopy Index your code
hub / github.com/automerge/automerge-codemirror

github.com/automerge/automerge-codemirror @v0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.0 ↗ · + Follow
28 symbols 74 edges 12 files 0 documented · 0% updated 11mo agov0.2.0 · 2025-07-21★ 382 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Automerge + Codemirror

This plugin adds collaborative editing to codemirror using automerge-repo.

Example

import { Repo } from "@automerge/automerge-repo";
import { automergeSyncPlugin } from "@automerge/automerge-codemirror";
import { EditorView } from "@codemirror/view"
import { basicSetup } from "codemirror"

// Setup a repo and create a doc handle. In practice you'll probably get a
// DocHandle by loading it from a document URL
const repo = new Repo(..)
const doc = repo.create({text: ""})

// Setup the codemirror view
const container = document.createElement("div")
const view = new EditorView({
  doc: handle.doc().text,
  extensions: [
    basicSetup,
    automergeSyncPlugin({
      handle,
      path: ["text"],
    }),
  ],
  parent: container,
})

Automerge Repo 1.0 Compatibility

This codemirror plugin is intended for use with automerge-repo 2.0. That means that the interface it expects to be passed as the handle argument matches the signature of the DocHandle interface in automerge-repo 2.0. The main difference with automerge-repo 1.0 is that the automerge 1.0 DocHandle.doc method is asynchronous. If you can't upgrade to automerge-repo 2.0 then you can get around this by wrapping the 1.0 handle in an object which uses the 1.0 DocHandle.docSync method to implement the DocHandle.doc method. Like so:

import { type DocHandle } from "@automerge/automerge-codemirror"
import { type DocHandle as RepoHandle } from "@automerge/automerge-repo"

// Convert an automerge-repo 1.0 DocHandle to the interface this plugin expects
function makeHandle<T>(h: RepoHandle<T>): DocHandle<T> {
    return Object.assign({}, h, {
        doc: () => h.docSync(),
    })
}

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 17
Method 7
Class 2
Interface 2

Languages

TypeScript100%

Modules by API surface

src/plugin.ts7 symbols
src/amToCodemirror.ts7 symbols
src/DocHandle.ts5 symbols
test/Editor.cy.tsx4 symbols
test/Editor.tsx3 symbols
src/codeMirrorToAm.ts1 symbols
cypress/support/component.ts1 symbols

For agents

$ claude mcp add automerge-codemirror \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page