1 | import richText from 'rich-text'
|
2 | import Racer from 'racer'
|
3 | import RacerRemoteDoc from 'racer/lib/Model/RemoteDoc'
|
4 | import Query from 'racer/lib/Model/Query'
|
5 | import { promisifyAll } from 'bluebird'
|
6 | import batch from './batch'
|
7 | import ormPlugin from '@startupjs/orm'
|
8 |
|
9 | export default (ShareDB, { orm } = {}) => {
|
10 |
|
11 | ShareDB.types.register(richText.type)
|
12 |
|
13 |
|
14 | let oldRemoteDocOnOp = RacerRemoteDoc.prototype._onOp
|
15 | RacerRemoteDoc.prototype._onOp = function () {
|
16 | if (this.shareDoc.type === richText.type) return
|
17 | return oldRemoteDocOnOp.apply(this, arguments)
|
18 | }
|
19 |
|
20 |
|
21 | promisifyAll(Racer.Model.prototype)
|
22 | promisifyAll(Query.prototype)
|
23 |
|
24 |
|
25 | Racer.Model.prototype.batch = batch
|
26 |
|
27 | if (orm) {
|
28 | Racer.use(ormPlugin)
|
29 | Racer.use(orm)
|
30 | }
|
31 | }
|