Skip to content

Commit

Permalink
Make ot-socialcalc default ottype
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelklehr committed Oct 8, 2016
1 parent 8f4575f commit f39dab7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ It utilizes the [ot-socialcalc](https://github.com/marcelklehr/ot-socialcalc) OT
## Install

```
npm install --save gulf gulf-editor-codemirror ot-socialcalc
npm install --save gulf-editor-codemirror
```

## Usage

```js
const gulf = require('gulf')
const socialcalcOT = require('ot-socialcalc')
const SocialcalcDocument = require('gulf-editor-socialcalc')

var doc = new SocialcalcDocument({
storageAdapter: new gulf.MemoryAdapter
, ottype: socialcalcOT
, editorInstance: socialcalcControl
editorInstance: socialcalcControl
})

masterStream.pipe(doc.masterLink()).pipe(masterStream)
Expand All @@ -29,8 +25,8 @@ masterStream.pipe(doc.masterLink()).pipe(masterStream)
## API
### class CodemirrorDocument({editorInstance:SocialcalcControl, ...}) extends gulf.EditableDocument
* `editorInstance` -- a SocialcalcControl instance to be wired up with gulf
* `storageAdapter` -- a gulf storage adapteir
* `ottype` -- the ottype to use, this will usually be `ot-socialcalc` from npm.
* `storageAdapter` -- (optional) a gulf storage adapter. Default: `gulf.MemoryAdapter`
* `ottype` -- (optional) the ottype to use. Default: `ot-socialcalc`

## Legal
(c) 2016 by Marcel Klehr
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
var gulf = require('gulf')
, socialcalcOT = require('ot-socialcalc')
, SocialCalc = require('socialcalc')

require('./socialcalc_patches')

class SocialcalcDocument extends gulf.EditableDocument {
constructor(opts) {
opts.ottype = opts.ottype || socialcalcOT
super(opts)
if (!opts.editorInstance) throw new Error('No SocialCalc instance was passed')
this.socialcalcControl = opts.editorInstance
Expand Down

0 comments on commit f39dab7

Please sign in to comment.