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