Socket
Socket
Sign inDemoInstall

automerge-codemirror

Package Overview
Dependencies
20
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    automerge-codemirror

Automerge plugin for CodeMirror


Version published
Maintainers
2
Install size
10.0 MB
Created

Changelog

Source

[6.0.0]

Changed

  • Removed dependency on Automerge.WatchableDoc
  • Completely changed the public API again :-(

Readme

Source

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

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 = (
  <AutomergeCodeMirror
    makeCodeMirror={(element) => 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.

FAQs

Last updated on 08 May 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc