JSPM

@jsonjoy.com/collaborative-codemirror

18.12.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 567
  • Score
    100M100P100Q95528F
  • License AGPL-3.0-only

Binding for collaborative editing support in CodeMirror Editor. Connects JSON CRDT str node to CodeMirror Editor.

Package Exports

  • @jsonjoy.com/collaborative-codemirror
  • @jsonjoy.com/collaborative-codemirror/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jsonjoy.com/collaborative-codemirror) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

CodeMirror collaborative binding

Makes a plain CodeMirror editor instance collaborative by binding it to a JSON CRDT document str node. This allows multiple users to edit the same document json-joy JSON CRDT document concurrently through the CodeMirror editor.

collab-codemirror-demo

Usage

Installation:

npm install json-joy @jsonjoy.com/collaborative-codemirror codemirror

Usage:

import {EditorView} from 'codemirror';
import {bind} from '@jsonjoy.com/collaborative-codemirror';
import {Model, s} from 'json-joy/lib/json-crdt';

// Create a JSON CRDT model.
const model = Model.create(s.str(''));

// Create a CodeMirror editor instance.
const editor = new EditorView({parent: div});

// Connect CodeMirror editor to JSON CRDT document "str" node.
const unbind = bind(() => model.s.toApi(), editor);

// When done, unbind the binding.
unbind();

Preview