collaborative-editor
TypeScript icon, indicating that this package has built-in type declarations

2.8.0 • Public • Published

Collaborative plain text editor binding

This package provides binding for a generic text editor to a JSON CRDT str node.

collaborative-editor

Usage

Installation:

npm install json-joy collaborative-editor

Simple integration for any plain text editor, for the most basic integration you only need to implement the .get() and .set() methods:

import {StrBinding, EditorFacade} from 'collaborative-editor';
import {Model} from 'json-joy/lib/json-crdt';

const str = model.api.str(['path', 'to', 'string']);
const unbind = StrBinding.bind(str, {
  get: () => input.value,
  set: (value: string) => input.value = value,
}, true);

For a better integration, implement as many EditorFacade methods as possible:

import {StrBinding, EditorFacade} from 'collaborative-editor';

const editor: EditorFacade = {
  // ...
};

const str = model.api.str(['path', 'to', 'string']);
const binding = new StrBinding(str, editor);

binding.syncFromModel();
binding.bind(polling);

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

Preview

Package Sidebar

Install

npm i collaborative-editor

Weekly Downloads

36

Version

2.8.0

License

none

Unpacked Size

61.9 kB

Total Files

35

Last publish

Collaborators

  • streamich