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

github.com/aslakhellesoy/automerge-codemirror @v6.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v6.0.0 ↗ · + Follow
49 symbols 118 edges 17 files 1 documented · 2% updated 3y ago★ 33
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Automerge-CodeMirror

Node.js CI

Automerge-CodeMirror brings collaborative editing to CodeMirror by linking it to an Automerge.Text object.

You can have as many Automerge.Text objects as you want inside a single Automerge document, and link each of them to a separate CodeMirror instance. This is useful for applications that render many editable text areas (such as a Trello-like application with multiple cards).

It ships with a React component, but can also be used without React.

Installation

npm install automerge-codemirror

Live Demo

Check it out here

To run it locally:

yarn storybook

General Usage

import { connectAutomergeDoc } from 'automerge-codemirror'

// Create a connect function linked to an Automerge document
const connectCodeMirror = connectAutomergeDoc(watchableDoc)

// Connect a CodeMirror instance
const getText = (doc) => doc.text
const disconnectCodeMirror = connectCodeMirror(codeMirror, getText)

// Disconnect the CodeMirror instance
disconnectCodeMirror()

React Usage

```typescript jsx import { connectAutomergeDoc, AutomergeCodeMirror } from 'automerge-codemirror'

// Create a connect function linked to an Automerge document const connectCodeMirror = connectAutomergeDoc(watchableDoc)

// Connect a CodeMirror instance const getText = (doc) => doc.text const acm = ( CodeMirror(element)} connectCodeMirror={connectCodeMirror} getText={getText} /> ) ```

Synchronisation with other peers

Automerge-CodeMirror is agnostic of how you choose to synchronize the linked Automerge document with other peers. Just register a handler with the WatchableDoc that does the synchronization.

Extension points exported contracts — how you extend this code

TestDoc (Interface)
(no doc)
test/AutomergeCodeMirrorTest.ts
TestDoc (Interface)
(no doc)
test/updateAutomergeTextTest.ts
TestDoc (Interface)
(no doc)
test/updateCodeMirrorDocsTest.ts
Pad (Interface)
(no doc)
test/react/PadComponent.tsx
IProps (Interface)
(no doc)
src/react/AutomergeCodeMirrorComponent.tsx
TestDocWithManyTexts (Interface)
(no doc)
test/updateCodeMirrorDocsTest.ts
Props (Interface)
(no doc)
test/react/PadComponent.tsx

Core symbols most depended-on inside this repo

change
called by 25
test/manymerge/PeerDoc.ts
applyMessage
called by 7
test/manymerge/HubDoc.ts
updateCodeMirrorDocs
called by 7
src/updateCodeMirrorDocs.ts
updateCodeMirrors
called by 7
src/AutomergeCodeMirror.ts
connectCodeMirror
called by 5
src/AutomergeCodeMirror.ts
randomPositiveInt
called by 3
test/random.ts
updateAutomergeText
called by 3
src/updateAutomergeText.ts
randomString
called by 2
test/random.ts

Shape

Function 19
Method 15
Class 8
Interface 7

Languages

TypeScript100%

Modules by API surface

test/react/PadComponent.tsx7 symbols
test/manymerge/PeerDoc.ts7 symbols
src/AutomergeCodeMirror.ts7 symbols
src/Mutex.ts5 symbols
test/manymerge/HubDoc.ts4 symbols
test/updateCodeMirrorDocsTest.ts3 symbols
test/updateAutomergeTextTest.ts3 symbols
test/codeMirrorEnv.ts3 symbols
test/AutomergeCodeMirrorTest.ts3 symbols
test/random.ts2 symbols
src/react/AutomergeCodeMirrorComponent.tsx2 symbols
test/react/AutomergeCodeMirrorComponentTest.tsx1 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