Skip to content

Base class for binding sharedb text diff data operations sent to a generic HTML element.

Notifications You must be signed in to change notification settings

stanographer/sharedb-generic-binding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sharedb-generic-binding

Base class for binding sharedb's text diff data operations sent to a generic HTML element. Implementation of curran's commit to enable StringBinding, binding.setup() on non-textarea HTML elements.

Usage

npm install sharedb-generic-binding --save

Then use familiar code to bind to a ShareDB connection.

// Require it.
const ShareGenericBinding = require('sharedb-generic-binding');

// Setup the connection.
const socket = new WebSocket('ws://YOUR_HOST:YOUR_PORT', [], socketOptions);
const connection = new sharedb.Connection(socket);
const doc = connection.get('examples', 'textarea');

// Subscribe to the document.
doc.subscribe((err) => {
  if (err) throw err;
  const element = document.getElementById('YOUR_DIV_OR_WHATEVER');
  const binding = new ShareGenericBinding(element, doc);
  binding.setup();
});

About

Base class for binding sharedb text diff data operations sent to a generic HTML element.

Resources

Stars

Watchers

Forks

Packages

No packages published