How to use the sharedb/lib/client.types function in sharedb

To help you get started, we’ve selected a few sharedb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chili-epfl / collab-react-components / src / client / index.js View on Github external
/**
 * Created by dario on 11.05.17.
 */

import ShareDB from 'sharedb/lib/client';
import RichText from 'rich-text';
import CollabForm from './CollabForm';
import CollabEditor from './CollabEditor';
import CollabRichEditor from './CollabRichEditor';
import { Quill } from 'react-quill';
import DragAndDropModule from './DragAndDropModule';

// Register rich-text type on the client
ShareDB.types.register(RichText.type);

// Register module Drag and Drop into Quill
Quill.register('modules/dragAndDrop', DragAndDropModule);

export { CollabForm, CollabEditor, CollabRichEditor };
github derbyjs / racer / lib / Model / bundle.js View on Github external
var Model = require('./Model');
var defaultType = require('sharedb/lib/client').types.defaultType;

Model.BUNDLE_TIMEOUT = 10 * 1000;

Model.INITS.push(function(model, options) {
  model.root.bundleTimeout = options.bundleTimeout || Model.BUNDLE_TIMEOUT;
});

Model.prototype.bundle = function(cb) {
  var root = this.root;
  var timeout = setTimeout(function() {
    var message = 'Model bundle took longer than ' + root.bundleTimeout + 'ms';
    var err = new Error(message);
    cb(err);
    // Keep the callback from being called more than once
    cb = function() {};
  }, root.bundleTimeout);
github derbyjs / racer / lib / Model / Query.js View on Github external
var util = require('../util');
var Model = require('./Model');
var defaultType = require('sharedb/lib/client').types.defaultType;

module.exports = Query;

Model.INITS.push(function(model) {
  model.root._queries = new Queries();
});

Model.prototype.query = function(collectionName, expression, options) {
  // DEPRECATED: Passing in a string as the third argument specifies the db
  // option for backward compatibility
  if (typeof options === 'string') {
    options = {db: options};
  }
  return this._getOrCreateQuery(collectionName, expression, options, Query);
};
github sillsdev / web-languageforge / src / node / client.js View on Github external
var ShareDB = require('sharedb/lib/client');
var richText = require('rich-text');
ShareDB.types.register(richText.type);

// Open WebSocket connection to ShareDB server
var socket = new WebSocket(getWebSocketDocUrl());
var connection = new ShareDB.Connection(socket);

var docSubs = {};
var onTextChanges = {};
var onOps = {};
var realTime = {};

function getWebSocketDocUrl() {
  var url = 'wss://' + window.location.host;
  return (url.endsWith(':8443')) ? url : url + ':8443';
}

realTime.createAndSubscribeRichTextDoc =
github share / sharedb / examples / rich-text / client.js View on Github external
var ReconnectingWebSocket = require('reconnecting-websocket');
var sharedb = require('sharedb/lib/client');
var richText = require('rich-text');
var Quill = require('quill');
sharedb.types.register(richText.type);

// Open WebSocket connection to ShareDB server
var socket = new ReconnectingWebSocket('ws://' + window.location.host);
var connection = new sharedb.Connection(socket);

// For testing reconnection
window.disconnect = function() {
  connection.close();
};
window.connect = function() {
  var socket = new ReconnectingWebSocket('ws://' + window.location.host);
  connection.bindToSocket(socket);
};

// Create local Doc instance mapped to 'examples' collection document with id 'richtext'
var doc = connection.get('examples', 'richtext');
github nicktogo / coeditor / lib / coeditor.js View on Github external
'use babel';

import CoeditorView from './coeditor-view';
import { CompositeDisposable, Range } from 'atom';
import ShareDB from 'sharedb/lib/client';
import otText from 'ot-text';
import WebSocket from 'ws';
import crypto from 'crypto';
import path from 'path';
import EventHandler from './EventHandler';
import Router from './router';

ShareDB.types.register(otText.type);

export default {

  // config of this package
  config: {
    serverAddress: {
      type: 'string',
      default: '192.168.1.175:9090',
      order: 1
    },
    clientId: {
      type: 'string',
      default: crypto.randomBytes(5).toString('hex'),
      order: 2
    },
    indicatorBackgroundColor: {
github pedrosanta / quill-sharedb-cursors / public / javascripts / main.js View on Github external
var ShareDB = require('sharedb/lib/client');
var Quill = require('quill');
var ReconnectingWebSocket = require('reconnectingwebsocket');
var cursors = require('./cursors' );
var utils = require('./utils');

import QuillCursors from 'quill-cursors/src/cursors';

ShareDB.types.register(require('rich-text').type);

Quill.register('modules/cursors', QuillCursors);

var shareDBSocket = new ReconnectingWebSocket(((location.protocol === 'https:') ? 'wss' : 'ws') + '://' + window.location.host + '/sharedb');

var shareDBConnection = new ShareDB.Connection(shareDBSocket);

var quill = window.quill = new Quill('#editor', {
  theme: 'snow',
  modules: {
    cursors: {
      autoRegisterListener: false
    },
    history: {
      userOnly: true
    }